Sikuli IDE命令等待(“图像”)不等待脚本继续之前出现的图像

时间:2017-12-19 13:07:03

标签: sikuli sikuli-ide

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

等待并单击使用cmd并且它们正在工作,我面临的问题是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"

outputLog:

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

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

2 个答案:

答案 0 :(得分: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

答案 1 :(得分:0)

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

  

地区:发现: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)

这可能会有所启发。