屏幕分辨率:
$ adb shell wm size
Physical size: 1080x2340
获取设备的最大X和Y: 为8639 18719
$ adb shell getevent -p | grep -e "0035" -e "0036"
0035 : value 0, min 0, max 8639, fuzz 0, flat 0, resolution 0
0036 : value 0, min 0, max 18719, fuzz 0, flat 0, resolution 0
计算比例:
1080 / 8639 = 0.125
2340 / 18719 = 0.125
获取点击的坐标:
adb shell getevent -l | grep -Ei "ABS_MT_POSITION_Y|ABS_MT_POSITION_X"
/dev/input/event3: EV_ABS ABS_MT_POSITION_X 00001ced 7405
/dev/input/event3: EV_ABS ABS_MT_POSITION_Y 00001b86 7406
真实的坐标:
7405* 0.125 = 925
7406* 0.125 = 925
模拟点击事件:
adb shell input tap 915 925
参考:Android shell获取和模拟点击事件_adb shell getevent -p-CSDN博客