21

This might seem like a duplicate question, but hear me out.

I basically need to press "CTRL+V" inside of Android. I need to paste the current Android clipboard into the focused TextBox.

So this:

adb shell input text [text]

won't do, as it requires me to enter the text myself. I just need to paste the current clipboard.

Is that possible through ABD? I googled and googled and all I found was ways to set clipboard content and not actually just press the paste button.

for the sake to ease development

Dysanix Official
  • 842
  • 1
  • 10
  • 18
  • @adelphus the clipboard on the device. As you would just "CTRL+V" on windows, I just need to "CTRL+V" on Android if you know what I mean. – Dysanix Official May 11 '16 at 21:46
  • Not directly through adb. If you have root, you could create a background system service that responds to an intent, and upon receiving the intent, inject a key sequence equivalent to paste (Ctrl + V). – Cookster May 11 '16 at 21:50
  • Since pasting is normally a hold and tap operation on the EditText, could you simulate taps in the appropriate positions - like in http://stackoverflow.com/questions/3437686/how-to-use-adb-to-send-touch-events-to-device-using-sendevent-command – adelphus May 11 '16 at 21:51

2 Answers2

18

Since API 24, KEYCODE_PASTE is available from the KeyEvent class, its constant is 279.

The adb command would be as follows:

adb shell input keyevent 279
Micer
  • 8,731
  • 3
  • 79
  • 73
Laraconda
  • 667
  • 6
  • 15
  • No responds why – Saige Zhang Sep 02 '18 at 18:52
  • This command is great! If you're also looking for a way to SET the clipboard over adb, you can install this app on your device: https://github.com/PRosenb/AdbClipboard. With this app you just need to broadcast a url encoded string and it will get set to the devices clipboard (works with spaces, special characters, emojis, etc). – Calvin Schemanski Dec 20 '19 at 16:28
0

My solution:

  1. I installed the Tasker plugin.
  2. I made a "scene" with a button.
  3. On the button tap event I added the "Control+V plugin" with the configuration to type %CLIP.
  4. Now I made a profile that direct to a task to show the scene (overlay,blocking).
  5. And last but not least, I use adb shell input tap x y to tap the button.
Dysanix Official
  • 842
  • 1
  • 10
  • 18