adb 類比人機互動事件

來源:互聯網
上載者:User

標籤:

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 類比人機互動事件

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.