Created
November 20, 2012 19:11
Fast keyboard input to Android from your development machine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env monkeyrunner | |
import sys | |
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice | |
print "Waiting for device..." | |
device = MonkeyRunner.waitForConnection() | |
print "Getting input arguments..." | |
input_text = sys.argv[1] | |
print "Typing.." | |
for token in input_text: | |
if token != " ": | |
device.type(token) | |
else: | |
device.press("KEYCODE_SPACE", MonkeyDevice.DOWN_AND_UP) | |
print "Done typing." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
input_text="echo hello world this is a test" | |
adb_input=$( | |
for (( i=0; i<${#input_text}; i++ )); do | |
current_token=${input_text:$i:1} | |
if [ "$current_token" = " " ]; then | |
echo -e "input keyevent 62" | |
else | |
echo -e "input text $current_token" | |
fi | |
done) | |
echo -e "$adb_input\nexit" | adb -d shell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment