zoukankan      html  css  js  c++  java
  • android adb shell input各种妙用

    项目中使用一个开发版,预留两个usb接口。类似华硕TinkerBoard。


    一个用户连接摄像头,一个用于adb调试。结果就没了鼠标的接口。
    多次切换鼠标和摄像头插头,非常不方便,带摄像头的app没法调试。
    于是各种查资料,发现了adb shell input这个命令,堪称神器。

    $ adb shell input --help
    Error: Unknown command: --help
    Usage: input [<source>] <command> [<arg>...]
    
    The sources are:
          trackball
          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)

    adb shell input相关的操作有text、keyevent、tap、swipe、(press、roll轨迹球这两个操作已经无用)
    分别对应输入文本、功能键、点击、滑动(长按)

    1. 输入文本:
    adb shell input text 12345
    输入12345文本

    2. 功能键:
    adb shell input keyevent 4 返回
    adb shell input keyevent 66 确定
    adb shell input keyevent 67 删除;更多的keyevent键对应code值参考 http://www.cnblogs.com/chengchengla1990/p/4515108.html

    3. 点击:
    adb shell input tap 20 1000
    点击位置(20,1000)

    4. 滑动(长按)
    adb shell input swipe 10 20 100 200
    从(10,20)滑动到(100,200)
    长按的技巧
    最后加一个参数,表示操作的时间ms,如
    adb shell input swipe 100 200 500 600 900 从(100,200)滑动到(500,600)总花费900ms
    adb shell input swipe 1400 400 1400 400 900 长按(1400,400) 900ms

  • 相关阅读:
    迷上了塔防游戏Desktop Tower Defense 1.5
    魔方成长路线
    排名进1000
    终于造完了863项目的预算
    利用supermemo背单词达到3000词条
    被Colorgraphic古老的Xentera多屏显卡折腾得不轻
    队式桥牌赛总结(20080503)
    在IIS上设置Gzip压缩设置(备忘)
    警惕使用WebClient.DownloadFile(string uri,string filePath)方法
    WebClient.UploadValues Post中文乱码的解决方法
  • 原文地址:https://www.cnblogs.com/zzugyl/p/7515004.html
Copyright © 2011-2022 走看看