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

  • 相关阅读:
    正则表达式30分钟入门教程
    Python的神奇方法指南
    Python 2.7教程
    javaweb开发.常用的第三方包
    javaweb开发.页面中文乱码问题
    javaweb开发.eclipse使用小常识
    javaweb开发3.基于Servlet+JSP+JavaBean开发模式的用户登录注册
    ionic3使用第三方图标
    json-server使用及路由配置
    javaweb开发2.新建一个javaweb项目
  • 原文地址:https://www.cnblogs.com/zzugyl/p/7515004.html
Copyright © 2011-2022 走看看