← Back to team overview

sikuli-driver team mailing list archive

[Question #634470]: Restart script on change

 

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

I'm looking for the best way to restart my script from the beginning when an image changes on my screen. So far I am using this code:

def changed(event):
    restart=True

restart=False
region.onChange(100, changed)
region.observe(background=True)

while True:
    #do stuff
    if not restart:
        #do stuff

region.stopObserver()

it kind of works but it's not entirely satisfying because sometimes, the if condition will be true just before the change is detected so the code inside the if condition will be executed when it's not supposed to be.

Is there a better way to do that?

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