Infinite Loop isn't working

Asked by Maurice Richard

Hello,

I have a very simple loop, that's refusing to work for me.

while True:
     if exists(myImage):
          ProcessConfirmations()
     else:
          wait(1.0)
          click(RefreshButton)

If it detects 'myImage' it runs 'ProcessConfirmations' fine.
But if it doesn't, it isn't running the else statement at all.
It just hangs there, and doesn't even error out.

I appreciate the help,
Maurice

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
Maurice Richard
Solved:
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

how do you know, that the else branch is not running?

Revision history for this message
Maurice Richard (flashfires) said :
#2

Hello RaiMan,

This was a problem with the user, so you can delete the question if you like.

I could tell the else branch wasn't running because it was supposed to click a button.
And it wasn't clicking that button ... or doing much of anything.

The problem was that the image in the if statement was getting a false positive.
The image has 2 states, but they were too similar for the program to see the difference.
I've made them easier to distinguish, and it's behaving normally now.

Thanks for the quick response!
Maurice