If Exits(() finds pattern that is not there

Asked by Thomas Geiger

I have developed a script, very simple, to automate clicking buttons in a game when an initial image appears. I want this to keep checking forever. Here is the script:

1 App.focus("Andy")
2 while True:
3 if exists(1.png, FOREVER):
4 click(1.png) #Click button that has appeared
5 click(2.png) #Click button on second screen that opens after first button click
6 click(3.png) #Click button on second screen that returns it to the first
7 else:
8 pass
9 wait (10)

The problem is, the first time through it works fine. But after that, the script progresses to line 5 and returns an error that 2.png can't be found.

Why does it even go to that line when 1.png is not present?

Thanks for any help!

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
Thomas Geiger
Solved:
Last query:
Last reply:
Revision history for this message
Thomas Geiger (thomas-geiger) said :
#1

Please ignore the facts that the indents didn't show up, the script is indented correctly.

Revision history for this message
RaiMan (raimund-hocke) said :
#2

I guess, this is because something similar to 1.png is found even if YOU do not see it at the expected place.

As a first check you might simply run in slow motion, to see, what is found as 1.png.

read this to understand how SikuliX works:
http://sikulix-2014.readthedocs.org/en/latest/basicinfo.html#sikulix-how-does-it-find-images-on-the-screen

I recommend to switch to version 1.1.0 that has more debugging options (http://sikulix.com)

Revision history for this message
Thomas Geiger (thomas-geiger) said :
#3

Agh, I figure out the problem, too embarassed to even say what it was.
Thanks!