简体   繁体   English

使用 adb 向 android 设备发送双击命令

[英]Fire double tap command to android device using adb

I have been trying to send a command to my device to double tap on the screen.我一直在尝试向我的设备发送命令以双击屏幕。 I tried to send this我试图发送这个

adb shell input tap 600 1000
adb shell input tap 600 1000

However, it does not result into a doubletap.但是,它不会导致双击。 Anyone willing to help me out?有人愿意帮助我吗?

This has worked for me pretty reliably until android 10;在 android 10 之前,这对我来说非常可靠; however, it no longer works on android 11:(但是,它不再适用于 android 11:(

I figured out a way to do it like this:我想出了一种方法来做到这一点:

input tap <x> <y>&
sleep 0.1
input tap <x> <y>

as in如在

adb shell "input tap 520 1150& sleep 0.1; input tap 520 1150" adb shell “输入抽头 520 1150& 睡眠 0.1;输入抽头 520 1150”

When digging around android 11 it seems that input command spawns up a JVM that is very slow, and it slowed down enough on android 11 to about 0.5 seconds, so the system does not recognize it as a double tap.在 android 11 附近挖掘时,输入命令似乎产生了一个非常慢的 JVM,并且它在 android 11 上的速度足够慢,因此系统无法识别它为 0 秒。

You can speed up the taps (or any user input) by including it in the same adb shell command.您可以通过将它包含在同一个 adb shell 命令中来加速点击(或任何用户输入)。 Previously I did this:以前我是这样做的:

adb shell "input tap 520 1150; input tap 520 1150" adb shell “输入抽头 520 1150;输入抽头 520 1150”

This will be easier on your system memory (as only one input command is executing at once) and may work pre android 11, but the one with & and explicit sleep between the two taps is what I switched to now.这在您的系统 memory 上会更容易(因为一次只执行一个输入命令)并且可能在 android 11 之前工作,但是我现在切换到两个水龙头之间带有 & 和显式睡眠的那个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM