一、简单的adb命令,不需要手机root
1、滑动
adb shell input [touchscreen|touchpad] swipe x1 y1 x2 y2
touchscreen – 触摸屏幕,touchpad – 不知道是啥
swipe – 滑动、滑屏操作
x1 y1 x2 y2 – 滑动起始和终止位置的横纵轴坐标,举例如下:
adb shell input touchscreen swipe 450 66 110 66
2、点击
adb shell input [touchscreen|touchpad] tap x y
touchscreen – 触摸屏幕,touchpad – 不知道是啥
tap 点击的意思,和下面的swipe相对应
x,y – 要点击的位置的横纵轴坐标,举例如下:
adb shell input touchscreen tap 110 66
以上方法使用简单,但是也有缺陷,
缺陷1:
执行慢,命令发送过去之后执行有延时。不能实现快速点击。
缺陷2:
有时会出现命令没有执行的情况。执行不稳定。
二、通过adb 直接发送事件进行手机操控。(已在小米9pro中测试成功,手机已root。似乎也有没有执行的情况。还不确定。)
getevent -l 命令可以查看手机事件输出。
adb shell #进入安卓命令行
su #获取超级权限
gentvent