尝试使用python和adb使用变量到命令提示符

发布于 2025-02-08 08:38:37 字数 477 浏览 1 评论 0原文

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命令。我只是不知道如何传输这些变量并使它们在命令提示中有用。

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.

I'm trying to click on a point in a screen using python/ adb.
I know how to generate the random number, and also the adb command. I just don't know how to transfer those variables and make them useful in command prompt.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

扶醉桌前 2025-02-15 08:38:37

虽然您可以使用f-string包含变量值,但是

f'cmd /k adb.exe shell input tap {xpixel} {ypixel}'

如果不使用adbinput您使用更具体的库,则可能会更好/Github.com/dtmilano/androidviewclient/“ rel =“ nofollow noreferrer”> 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)

While you can include variable values using f-strings

f'cmd /k adb.exe shell input tap {xpixel} {ypixel}'

it might be better if instead of using adb and input you use a more specific library like AndroidViewClient/culebra or any other, to be able to do something. like this

#! /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)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文