当前位置:   article > 正文

adb模拟按键操作_adb draganddrop

adb draganddrop
  1. Usage: input [<source>] <command> [<arg>...]
  2. The sources are:
  3. dpad
  4. keyboard
  5. mouse
  6. touchpad
  7. gamepad
  8. touchnavigation
  9. joystick
  10. touchscreen
  11. stylus
  12. trackball
  13. The commands and default sources are:
  14. text <string> (Default: touchscreen)
  15. keyevent [--longpress] <key code number or name> ... (Default: keyboard)
  16. tap <x> <y> (Default: touchscreen)
  17. swipe <x1> <y1> <x2> <y2> [duration(ms)] (Default: touchscreen)
  18. draganddrop <x1> <y1> <x2> <y2> [duration(ms)] (Default: touchscreen)
  19. press (Default: trackball)
  20. roll <dx> <dy> (Default: trackball)

1.模拟文本输入操作

adb shell input text abc   -----模拟输入abc

2.通过键值模拟按键操作,键值参考

adb shell input keyevent 4 / adb shell input keyevent KEYCODE_BACK   -----模拟按back键

3.通过坐标模拟点击操作

adb shell input tap 300 500   -----点击横坐标300纵坐标500的点

4.通过坐标模拟滑动操作

adb shell input swipe 200 300 500 300 100   -----从(200,300)的点划到(500,300)的点,滑动时间100ms

5.通过坐标模拟拖动操作

adb shell input draganddrop 100 1220 500 620 2000   -----从(100,1220)的点拖动到(500,620)的点,滑动时间2000ms

6.通过坐标模拟长按操作

adb shell input swipe 200 300 201 301 2000   -----从(200,300)的点划到(201,301)的点,滑动时间2000ms,由于划动距离短,在一个图标之内则主观显示为长按操作

7.模拟实体键长按操作

通过 getevent & 获取实体键键值

  1. /dev/input/event4: 0001 0074 00000001
  2. /dev/input/event4: 0000 0000 00000000
  3. /dev/input/event4: 0001 0074 00000000
  4. /dev/input/event4: 0000 0000 00000000

0074为电源键键值,转换为十进制为116,编写如下脚本

  1. sendevent /dev/input/event4 1 116 1
  2. sendevent /dev/input/event4 0 0 0
  3. sleep 4
  4. sendevent /dev/input/event4 1 116 0
  5. sendevent /dev/input/event4 0 0 0

运行sh脚本可得长按电源键效果,详细参考android在adb下模拟长按事件

8.通过坐标/键值模拟同时按下两个键,用and连接

adb shell input keyevent KEYCODE_POWER and KEYCODE_MENU    -----电源键亮屏并滑动解锁

 

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/article/detail/56399
推荐阅读
相关标签
  

闽ICP备14008679号