Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Typing on an Android Device straight from computer?

Tags:

android

adb

Can you use ADB to type directly on an android device from a computer? If so, how?

like image 743
Fran Fitzpatrick Avatar asked Oct 20 '10 13:10

Fran Fitzpatrick


People also ask

Can I text an Android phone from my computer?

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.

How can I type on Android from PC?

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.

Can I use my computer to type on my phone?

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!

How do I enable physical keyboard on Android?

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.


3 Answers

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

like image 133
Manuel Barbe Avatar answered Oct 24 '22 22:10

Manuel Barbe


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"'

enter image description here

like image 45
Dan Dascalescu Avatar answered Oct 24 '22 23:10

Dan Dascalescu


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'"
like image 5
Giso Bartels Avatar answered Oct 24 '22 22:10

Giso Bartels