Sikuli脚本图像单击togg

2024-06-12 12:56:00 发布

您现在位置:Python中文网/ 问答频道 /正文

我不熟悉这一点,请原谅我的知识不足。在

我试图写一个脚本,不断寻找屏幕上的图像,并在它们出现时单击它们。另外,我在寻找通过击键切换脚本的功能 现在的问题是它发现图像很好。。但两者之间的延迟似乎是永远的。图像在那里停留了将近5秒钟,然后它看到它并点击它。有没有什么方法可以让它更快地查找图像?在

提前谢谢!在

到目前为止,我得到的是:

Settings.MoveMouseDelay = 0.0
running = True
def runHotkey(event):
    global running
    running = False

Env.addHotkey(Key.F1, KeyModifier.CTRL, runHotkey)
nox = switchApp("NoxPlayer 5.2.1.0")
while(nox.hasWindow() and running):
    if exists("img1.png"):
        click("img1.png")
    if exists ("img2.png"):
        click("img2.png")
    if exists("img3.png"):
        click("img3.png")
    if exists("img4.png"):
        click("img4.png")

Tags: 图像脚本if屏幕pngexistsrunningimg1
1条回答
网友
1楼 · 发布于 2024-06-12 12:56:00

1)可以在脚本中调整图像搜索算法参数

Vision.setParameter("MinTargetSize", 6) # A small value such as 6 makes the matching algorithm be faster. Vision.setParameter("MinTargetSize", 18) # A large value such as 18 makes the matching algorithm be more robust.

2)您也可以在if条件下使用超时设置。我在这里加了2秒作为超时

if exists("img1.png", 2): click("img1.png")

相关问题 更多 >