標籤:
1 在終端中輸入:adb shell
2 輸入input 會得到如下資訊:
Usage: input [<source>] <command> [<arg>...]
source : 事件來源
command : 命令
arg : 參數
The sources are:
trackball // 軌跡球,好像HTC hero3 有這個東西
joystick // 操縱杆
touchnavigation
mouse
keyboard // 鍵盤
gamepad
touchpad
dpad
stylus
touchscreen // 觸控螢幕
The commands and default sources are:
text <string> (Default: touchscreen)
keyevent [--longpress] <key code number or name> ... (Default: keyboard)
tap <x> <y> (Default: touchscreen)
swipe <x1> <y1> <x2> <y2> [duration(ms)] (Default: touchscreen)
press (Default: trackball)
roll <dx> <dy> (Default: trackball)
text : 文本輸入,參數為字串,使用兩個單引號引起來
在文本輸入框擷取焦點的時候,adb shell 中輸入 eg: input text ‘hello world‘,觀察效果
keyevent : 鍵盤事件,參數為鍵盤符對應的數字或者名稱
用來執行各種鍵盤事件,比如返回,點擊鍵盤上的某個按鈕等,eg: input keyevent 3 == 點擊home鍵
tap : 使用者點擊事件,參數為絕對螢幕座標
類比點擊操作: eg: input tap 100 100 => 點擊螢幕上座標值為(100,100)的點
swipe : 滑動事件,參數為滑動開始點和結束點的座標,
eg: input swipe 100 100 200 200 => 從點y1 (100,100) 滑動到 點y2(200,200) ,還可以指定滑動的時間,單位為ms
該命令還可以類比長按事件 eg: adb shell input touchscreen swipe 170 187 170 187 2000 長按點(170,187) 2s時間
press 沒太弄明白,使用之後類似於切換焦點
roll 沒有使用過,這裡就不做介紹了
adb 類比人機互動事件