← Back to team overview

sikuli-driver team mailing list archive

[Question #293439]: Wait for event in desktop surveillance for specified time and do something if timeout

 

New question #293439 on Sikuli:
https://answers.launchpad.net/sikuli/+question/293439

I'm trying to make a desktop surveillance that clicks a bottom if the expected pattern does not show up within a specified time. The desktop surveillance should then continue looking for the expected pattern, to see if the action caused the expected pattern to show up within the next time interval.
I would expect the following to loop until X shows up, and then click X. If X does not show up within 10 sec, Y should be clicked and the loop should restart. Note: If X appears, also Y disappears.

The following code clicks X and stops as it should if X is found, but it does not click Y if X is not found within 10 sec, but keeps waiting doing nothing. I'm not sure what I'm missing here. Please help.

found_X = False
times_not_found_X = 0
while found_X == False:
    if exists("X.png"):
        click("X.png")        
        found_X = True
    else:
        if times_not_found_X<= 10:
            wait(1)
            times_not_found_X += 1
        else:
            click("Y.png")
            times_not_found_X = 0

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.