Input 是否可以使用ADB shell创建自动触摸/保持脚本?

Input 是否可以使用ADB shell创建自动触摸/保持脚本?,input,touch,adb,Input,Touch,Adb,我正在尝试使用ADB建立一个自动触摸序列以进行测试,我已经搜索了几周关于如何创建暂停、长时间触摸等的信息,但运气不佳。 我知道如何使用以下方法进行轻触和滑动: input [touchscreen|touchpad] tap <x> <y> input [touchscreen|touchpad] swipe <x1> <y1> <x2> <y2> 输入[触摸屏|触摸板]点击 输入[触摸屏|触摸板]滑动 但我不确定是否可

我正在尝试使用ADB建立一个自动触摸序列以进行测试,我已经搜索了几周关于如何创建暂停、长时间触摸等的信息,但运气不佳。 我知道如何使用以下方法进行轻触和滑动:

input [touchscreen|touchpad] tap <x> <y>
input [touchscreen|touchpad] swipe <x1> <y1> <x2> <y2>
输入[触摸屏|触摸板]点击
输入[触摸屏|触摸板]滑动
但我不确定是否可以修改它们来创建我前面提到的东西(暂停、长时间触摸、保持)

创建一个序列时,一般脚本是什么样子的,例如:

轻触,轻触,轻触,轻触,暂停,长触,暂停,轻触,轻触,轻触,轻触,轻触,暂停,重复

例如,假设所有命令都发生在相同的
位置


非常感谢您的帮助。

您可以使用Android SDK附带的工具monkeyrunner来完成此操作

from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice, MonkeyView
device = MonkeyRunner.waitForConnection(timeout = 60, deviceId = "DEVICE_ID")
# DEVICE_ID is the device's serial number obtained by running adb devices

# to tap 4 times
for i in range(4):
    device.touch(x, y,MonkeyDevice.DOWN_AND_UP)

# to pause
MonkeyRunner.sleep(no_of_seconds)

# to long touch
device.touch(x, y,MonkeyDevice.DOWN)
MonkeyRunner.sleep(no_of_seconds)
# to release the hold
device.touch(x, y,MonkeyDevice.UP)
现在,要在重复循环中包含所有这些,可以使用python while或for语句

monkeyrunner
位于
Android sdk/tools/monkeyrunner

下一步运行它,您将进入Jython 2.5.3的交互式控制台

或者通过
monkeyrunner../Desktop/level.py运行保存的脚本