← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #634470]: Restart script on change

 

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

Description changed to:
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):
    event.stopObserver()
    global restart
    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.