import os
import random
xpixel = random.randint(359,402)
ypixel = random.randint(256,368)
trest = random.randint(10,16)
print(trest)
time.sleep(trest)
print(xpixel)
print(ypixel)
os.system('cmd /k adb.exe shell input tap xpixel ypixel') <----I know this part is absolutly wrong but the concept is to be able to input those two numbers into command prompt some how.
我正在尝试使用python/ adb点击屏幕上的一个点。我知道如何生成随机数,以及adb命令。我只是不知道如何传递这些变量并使它们在命令提示符中有用。
发布于 2022-06-17 16:15:54
,而您可以使用f-字符串包含变量值。
f'cmd /k adb.exe shell input tap {xpixel} {ypixel}'
与其使用adb
和input
,不如使用更具体的库,比如AndroidViewClient/culebra或其他库,以便能够做一些事情。像这样
#! /usr/bin/env python3
import time
import random
from com.dtmilano.android.viewclient import ViewClient
device, serialno = ViewClient.connectToDeviceOrExit()
xpixel = random.randint(359,402)
ypixel = random.randint(256,368)
trest = random.randint(10,16)
print(trest)
time.sleep(trest)
print(xpixel)
print(ypixel)
device.touch(xpixel, ypixel)
https://stackoverflow.com/questions/72660973
复制相似问题