What is the basic difference between adb shell input keyevent
and adb shell sendevent
? Which one should I use for inputting a character? Are the ke
By the way, if you are trying to find a way to send double quotes to the device, try the following:
adb shell input text '\"'
I'm not sure why there's no event code for quotes, but this workaround does the job. Also, if you're using MonkeyDevice (or ChimpChat) you should test each caracter before invoking monkeyDevice.type, otherwise you get nothing when you try to send "
I wrote a simple Powershell script for windows users to map keys to adb shell input events. And controll an Android device remotely over LAN. I don't know if anyone finds it usefull, but I'll share it anyways.
$ip = 192.168.1.8
cd D:\Android\android-sdk-windows\platform-tools\; .\adb.exe disconnect $ip; .\adb.exe connect $ip
$adbKeyNum = @{LeftWindows = "1"; F1 = "3"; Enter = "66"; UpArrow = "19"; DownArrow = "20"; LeftArrow = "21"; RightArrow = "22"; Add = "24";
Subtract = "25"; Backspace = "4"; P = "26"}
while(1 -eq 1){
$keyPress = [Console]::ReadKey($true).Key
if ([string]$keyPress -eq "F10"){
.\adb.exe disconnect $ip
exit
}
elseif ([string]$keyPress -eq "F6"){
$string = Read-Host -Prompt 'Input the string: '
.\adb.exe shell input text $string
}
elseif ($adbKeyNum.ContainsKey([string]$keyPress)){
echo $adbKeyNum.Get_Item([string]$keyPress)
.\adb.exe shell input keyevent $adbKeyNum.Get_Item([string]$keyPress)
}
}