简体   繁体   English

Sikuli:无论模式是否存在,onAppear都可以工作

[英]Sikuli: onAppear works regardless of the pattern presence

As far as I understand onAppear is to evoke the handler in case the Pattern is on the screen. 据我了解,onAppear是在屏幕上出现Pattern的情况下唤起处理程序的。
However, when I'm running: 但是,当我跑步时:

paste(Pattern("123.png").targetOffset(-1,37),"testText")
wait(2)
onAppear("456.png", popup("Text1"))

Pop-up appears always, even if the pattern 456.png is not on the screen 即使模式456.png不在屏幕上,也会始终显示弹出窗口

Could you please advise, what I'm missing? 您能告诉我我所缺少的吗?

You're missing the observer call. 您错过了旁听者通话。 You can read more on observers in sikuli here 您可以在sikuli上阅读更多关于观察员的信息

Basically what you need to do is add the following line after your code: 基本上,您需要做的是在代码后添加以下行:

observe([your desired timeout in seconds], [background = True/False])

And don't forget to add the stopObserver() call if you don't set timeout. 如果您未设置超时,请不要忘记添加stopObserver()调用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM