所以我用python和adb为一个单人机器人游戏做了一个机器人。最大的问题是,每次点击之间都有大约1秒的延迟。
我像这样连接到这个设备-
from ppadb.client import Client
def Get_device_adb():
adb = Client(host="127.0.0.1", port=5037)
devices = adb.devices()
if len(devices) == 0:
print("No device attached")
quit()
return devices[0]
device = Get_device_adb()
并使用shell输入点击来发送我的点击-
taps = [(225, 750), (350, 800), ...]
for tap in taps:
device.shell(f"input tap {tap[0]} {tap[1]}")
对于游戏,我需要一个接一个地尽可能快地敲击,目前它们之间有1秒的延迟。
顺便说一下,我真的希望这个脚本在python中运行,而不是在jython中运行。
那么,有没有办法让亚行更快地使用呢?
发布于 2021-10-28 22:32:58
您可以使用CluebraTester2-public后端尝试AndroidViewClient/cuelbra,您可以获得更高的费率。
以下是一个示例脚本
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
import time
from com.dtmilano.android.viewclient import ViewClient
device, serialno = ViewClient.connectToDeviceOrExit()
kwargs2 = {'useuiautomatorhelper': True}
vc = ViewClient(device, serialno, **kwargs2)
taps = [(225, 750), (350, 800), (100, 100), (300, 300), (150, 150), (100, 200)]
for tap in taps:
print(f'{time.time()}: touching @{tap}')
vc.touch(tap[0], tap[1])
使用仿真器我可以获得
1635459899.020685: touching @(225, 750)
1635459899.202344: touching @(350, 800)
1635459899.522454: touching @(100, 100)
1635459899.703721: touching @(300, 300)
1635459899.8933198: touching @(150, 150)
1635459903.257416: touching @(100, 200)
这给出了大约。每200毫秒1次触摸。
https://stackoverflow.com/questions/69751137
复制相似问题