1

我是 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

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

4

2 回答 2

2

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

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")

您可以在此处找到模式文档

于 2017-12-19T14:47:32.290 回答
1

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

区域:查找: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)

这可能会有所启发。

于 2017-12-19T13:52:46.613 回答