Infinite Loop isn't working

Asked by Maurice Richard on 2020-02-03

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:
Sikuli Edit question
Assignee:
No assignee Edit question
Solved by:
Maurice Richard
Solved:
2020-02-03
Last query:
2020-02-03
Last reply:
2020-02-03
RaiMan (raimund-hocke) said : #1

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

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