python adb模拟输入_ADB——模拟手机按键输入
基本命令adb 模拟按键输入的命令主要通过 input 进行Usage: input [][...]The sources are:mousekeyboardjoysticktouchnavigationtouchpadtrackballstylusdpadgesturetouchscreengamepadThe commandsanddefault sources are:text(Defa..
基本命令
adb 模拟按键输入的命令主要通过 input 进行
Usage: input [] [...]
The sources are:
mouse
keyboard
joystick
touchnavigation
touchpad
trackball
stylus
dpad
gesture
touchscreen
gamepad
The commandsanddefault sources are:
text(Default: touchscreen)
keyevent [--longpress] ... (Default: keyboard)
tap(Default: touchscreen)
swipe[duration(ms)] (Default: touchscreen)
press (Default: trackball)
roll (Default: trackball)
参数解释
常用命令
物理键:
adb shell input keyevent 26 #电源键
adb shell input keyevent 82 #菜单键
adb shell input keyevent 3 #HOME 键
adb shell input keyevent 4 #返回键
adb shell input keyevent 24 #音量+
adb shell input keyevent 25 #音量-
adb shell input keyevent 164 #静音
媒体控制
adb shell input keyevent 85 #播放/暂停
adb shell input keyevent 86 #停止播放
adb shell input keyevent 87 #播放下一首
adb shell input keyevent 88 #播放上一首
adb shell input keyevent 126 #恢复播放
adb shell input keyevent 127 #暂停播放
点亮/熄灭屏幕
可以通过上 模拟电源键 来切换点亮和熄灭屏幕,但如果明确地想要点亮或者熄灭屏幕,那可以使用如下方法。
adb shell input keyevent 224 #点亮屏幕
adb shell input keyevent 223 #熄灭屏幕
触击屏幕
adb shell input tap #x,y为坐标位置
滑动屏幕
划动屏幕用到了 swipe 命令,它有四个参数,分别是起始点x坐标 起始点y坐标 结束点x坐标 结束点y坐标。
如果锁屏没有密码,是通过滑动手势解锁,那么可以通过 input swipe 来解锁。
#四个参数:起始点x坐标 起始点y坐标 结束点x坐标 结束点y坐标。
adb shell input swipe 300 1000 300 500 #向上滑动
adb shell input swipe 300 100 300 1000 #向下滑动
adb shell input swipe 1000 500 200 500 #向左滑动
adb shell input swipe 200 500 1000 500 #向右滑动
输入文本
在焦点处于某文本框时,可以通过 input 命令来输入文本。
adb shell input text hello #输入hello
keyevent 命令大全
更多推荐
所有评论(0)