Can you use ADB to type directly on an android device from a computer? If so, how?
Go to messages.android.com on the computer or other device you want to text from. You'll see a big QR code on the right side of this page. Open up Android Messages on your smartphone.
From the Basic Input screen, you can tap the keyboard icon at the bottom-left corner of the screen to pull up your smartphone keyboard. Type on the keyboard and it'll send that input to your computer. Other remote control functions can also be useful.
Install the application& go to Settings>Language & Keyboard. Now go to Input Method and select the WiFi keyboard. Then launch the app and switch on your WiFi in your phone. Now a new webpage is shown in the browser and in the text box, you can start typing!
On your phone, go to Settings and then the System page. Scroll down until you find the section entitled “OTG storage,” and turn on the option. When you connect the USB OTG cable to the physical keyboard, you will be able to use the keyboard to type on your phone.
Although this question is rather old, I'd like to add this answer:
You may use adb shell input keyevent KEYCODE
resp. adb shell input text "mytext"
. A list of all keycodes can be found here
As Manuel said, you can use adb shell input text
, but you need to replace spaces with %s
, as well as handle quotes. Here's a simple bash script to make that very easy:
#!/bin/bash
text=$(printf '%s%%s' ${@}) # concatenate and replace spaces with %s
text=${text%%%s} # remove the trailing %s
text=${text//\'/\\\'} # escape single quotes
text=${text//\"/\\\"} # escape double quotes
# echo "[$text]" # debugging
adb shell input text "$text"
Save as, say, atext
and make executable. Then you can invoke the script without quotes...
atext Hello world!
...unless you need to send quotes, in which case you do need to put them between the other type of quotes (this is a shell limitation):
atext "I'd" like it '"shaken, not stirred"'
To avoid expansion/evaluation of the text parameter (i.e. for special characters like '$' or ';'), you could wrap them into quotes like this:
adb shell "input text 'insert your text here'"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With