使用ADB模拟触摸
我正在尝试使用批处理文件(.bat)和 adb shell 发送触摸事件。
我尝试重新发送从 adb shell getevents 获得的事件,即使命令顺利通过,它也不起作用。 有什么想法吗?
如何使用 ADB shell 模拟给定 (x,y) 坐标上的触摸事件和释放事件?
I am trying to send touch events using batch files (.bat) and the adb shell.
I tried to re-send events I get from the adb shell getevents, and it doesn't work even though the command passes without errors.
Any ideas?
How do I simulate a touch-event and release-event on a given (x,y) coordinate using the ADB shell?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
由于它似乎会根据 Android 版本而变化,因此我建议您按照以下说明进行操作:
开始转储您需要重现的运动事件:
grep
对于过滤输出非常有用。执行您想要重现的动作事件;
然后将转储中的所有值从十六进制转换为十进制值! :)
要查找 eventX 正在为您工作,请执行以下操作:
启动终端并输入:
您将看到快速移动的痕迹,例如 /dev/input/event4 ......
您必须在 event4 之间看到几个 eventX 以及这些 eventX 就在触摸的瞬间
将成为您再现运动事件的输入界面! :)
来源。
Since it seems to change depending on the Android version, I suggest you to follow these instructions :
Start dump motion event you need to reproduce:
grep
is very useful to filter output.Do motion event you want to reproduce;
Then just convert all values from hex in dump to decimal values! :)
To find what eventX is working for you do following:
Start terminal and type:
You will see quickly moving traces with for example /dev/input/event4 ......
You must see between event4 few eventX and these eventX right in the moment of the touch
will be yours input interface for reproducing motion events! :)
Source.
我设法在 sony xperia LT26i 上模拟该事件
通过使用
捕获输入然后将所有值从十六进制转换为十进制,
并通过将生成的序列放入 shellscript 中,
我从链接论坛的帖子中发现,第 2 行和第 3 行正在设置 X 和 Y 位置
接下来的 2 行是触摸按下,底部 2 行是触摸释放,我还没有弄清楚第一行的作用,但它需要它才能工作。
我希望这对你有用
I managed to emulate the event on sony xperia LT26i
by using
to capture input and then converting all values from hex to decimal,
and by putting the generated sequence in a shellscript
I figured from posts in linked forum that line 2 and 3 are setting X and Y position
the next 2 lines are touch press and the bottom 2 lines are touch release, I havent figured out what the first line does yet but it is needed for it to work.
I hope this is useful to you