您的位置:首页 > 移动开发 > Android开发

Android通过代码模拟物理、屏幕点击事件

2015-12-23 15:36 821 查看
http://blog.csdn.net/mad1989/article/details/38109689

在未root的手机上都可以用 adb shell 发送按键, 触摸屏事件,monkeytest就是用这些指令操作的。

使用 getevent -p 查看当前输入设备

使用下面两组指令发送 Power 键给手机:

sendevent /dev/input/event0 1 102 1

sendevent /dev/input/event0 1 102 0

使用 input 指令发送触摸点击事件:

input tap xxx, yyy

shell@mx5:/ $ input tap 400 800

shell@mx5:/ $ input touchscreen 400 800

Error: Unknown command: 400

Usage: input [<source>] <command> [<arg>...]

The sources are:

mouse

keyboard

joystick

touchnavigation

touchpad

trackball

stylus

dpad

touchscreen

gamepad

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)

shell@mx5:/ $
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: