【问题标题】:Sikuli IDE command wait("image") not waiting for image to appear before script continuesSikuli IDE 命令等待(“图像”)在脚本继续之前不等待图像出现
【发布时间】:2017-12-20 13:18:48
【问题描述】:

我是 Sikuli 的新手,正在尝试使用一个看起来像这样的非常简单的脚本...

等待并单击 cmds 已使用并且它们正在工作,我面临的问题是 wait("1513068228396.png",3600) 不等到图像出现,它等待大约 10 到 15 秒并执行下一个 cmd。我尝试包含一些日志,并尝试使用其他图像来相同的等待 cmd,仍然是相同的结果。

wait("1513067960826.png",60)
click(Pattern("1513066493827.png").targetOffset(-106,2))
sleep(2)
click("1513066637741.png")
sleep(1)
click("1513599247108.png")
sleep(5)
print "wait for my image"

wait("1513068228396.png",3600)  # Facing issue in this line

print "found my image"

输出日志:

wait for my image
[debug] Region: find: waiting 3600.0 secs for 1513068228396.png to appear in R[0,0 1920x1080]@S(0)
[debug] Image: reused: 1513068228396.png (file:/D:/softwares/sikuli/SENINFO_V100R002C00SPC700.sikuli/1513068228396.png)
[debug] Region: checkLastSeen: not there
[debug] Region: find: 1513068228396.png has appeared at M[832,379 30x16]@S(S(0)[0,0 1920x1080]) S:0.70 C:847,387 [753 msec]
found my image

任何建议如何解决这个问题。

【问题讨论】:

    标签: sikuli sikuli-ide


    【解决方案1】:

    也许该图像与屏幕中的某些区域有相似之处。您可以尝试将相似度设置为最大值:

    wait(Pattern("some_image.png").similar(0.8),) # if you want the 80% of similarity
    wait(Pattern("some_image.png").exact()) # if you want the 100% of similarity
    

    另外,我鼓励你使用 if exists 而不是 wait。如果图像不存在,Wait 将结束程序:

    if exists(Pattern("some_image.png").exact(),3600):
        click("some_image.png")
    

    你可以找到模式文档here

    【讨论】:

    • wait(Pattern("some_image.png").similar(0.8),3600) 这行代码解决了问题,谢谢.. :)
    【解决方案2】:

    wait(pattern, 3600) 等价于 wait(pattern, FOREVER),描述为 here 并将无限期地等待模式。在像你这样的情况下,唯一可以解释这种行为的是,如果模式实际上是在屏幕上找到的,并且下面的行证实了这一点:

    Region: find: 1513068228396.png 已出现在 M[832,379 30x16]@S(S(0)[0,0 1920x1080]) S:0.70 C:847,387 [753 毫秒]

    也许这种模式出现在其他地方而你错过了?或者,相似性参数可能太低,而另一个模式被识别出来。要检查,请尝试使用highlight(1) 方法。

    ptrn = find("pattern.png")
    ptrn.highlight(1)
    

    这可能会有所启发。

    【讨论】:

      猜你喜欢
      • 2012-01-28
      • 1970-01-01
      • 1970-01-01
      • 2018-06-19
      • 1970-01-01
      • 2020-04-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多