我想创建一个程序来自动连续点击屏幕Android手机。
我在循环中尝试了“adb shell input tap x y”,但速度很慢(大约1秒)。 我尝试了多个命令,例如:“adb shell input tap x1 y1 && adb shell input tap x2 y2”,但无法解决我的问题。
正如 @Robert 提到的,仅运行 1 个 adb shell,然后在循环中执行
input tap
会提高速度。
但是,避免每次都执行新的 input
,您可以获得更好的速率。
使用 AndroidViewClient/culebra 和 CulebraTester2-public 后端,您将能够获得这样的值。
#! /usr/bin/env python3
import timeit
from com.dtmilano.android.viewclient import ViewClient
helper = ViewClient.view_client_helper()
print(f"{timeit.timeit('helper.ui_device.click(500, 500)', number=1, globals=globals()):.4f}s")
给予(在模拟器上):
⚠️ CulebraTester2 server should have been started and localport 9987 redirected to remote port 9987.
0.1796s
这样你就可以跑了
helper.ui_device.click(x, y)
循环快速点击。