ADB Shell Input Events

前端 未结 8 1319
伪装坚强ぢ
伪装坚强ぢ 2020-11-22 11:50

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

相关标签:
8条回答
  • 2020-11-22 12:27

    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 "

    0 讨论(0)
  • 2020-11-22 12:30

    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)
        }
    }
    
    0 讨论(0)
提交回复
热议问题