[Sikuli-driver] [Question #689241]: Observer not stopping / causing script to a halt/slugghish execution
New question #689241 on Sikuli: https://answers.launchpad.net/sikuli/+question/689241 Please advise how I can properly write this better. It seems to be working but after a few min. The script seems to sit idle. I don't even think the observer is stopping correctly. I'm monitoring a specified region for changes (lots of movement in that region) and when it's found, clicks that region then continues with the script. Here's what I have: def boxObserve(): def changed(event): event.stopObserver() sleep(0.15) box.stopObserver() for chg in event.changes: box.stopObserver() sleep(0.25) event.changes[-1].click() #click on the last changed agrea doSomethingAfterClicking() #Do this after clicking box = Region(684,552,266,371) box.onChange(500, changed) box.observe(0.5,background=False) sleep(0.25) box.stopObserver() doSomethingIfNothingChanged() #Do this function if Observer didnt detect any changes. -- You received this question notification because your team Sikuli Drivers is an answer contact for Sikuli. ___ Mailing list: https://launchpad.net/~sikuli-driver Post to : sikuli-driver@lists.launchpad.net Unsubscribe : https://launchpad.net/~sikuli-driver More help : https://help.launchpad.net/ListHelp
Re: [Sikuli-driver] [Question #689241]: Observer not stopping / causing script to a halt/slugghish execution
Question #689241 on Sikuli changed: https://answers.launchpad.net/sikuli/+question/689241 Status: Open => Answered RaiMan proposed the following answer: looks like some stopObserver overkill ;-) my suggestion: def boxObserve(): def changed(event): global someChanges event.changes[-1].click() #click on the last changed area someChanges = True event.stopObserver() box = Region(684,552,266,371) box.onChange(500, changed) someChanges = False box.observe(0.5,background=False) if someChanges: doSomethingAfterClicking() #Do this after clicking else: doSomethingIfNothingChanged() #Do this function if Observer didnt detect any changes. some comments: - in a handler should not be lengthy activities, because the main thread is paused meanwhile - when the observe time is reached, the observer is stopped anyways - when the handler is visited, event.changes contains at least one entry - global variables can be used to communicate between handler and main thread hope it helps -- You received this question notification because your team Sikuli Drivers is an answer contact for Sikuli. ___ Mailing list: https://launchpad.net/~sikuli-driver Post to : sikuli-driver@lists.launchpad.net Unsubscribe : https://launchpad.net/~sikuli-driver More help : https://help.launchpad.net/ListHelp
Re: [Sikuli-driver] [Question #689241]: Observer not stopping / causing script to a halt/slugghish execution
Question #689241 on Sikuli changed: https://answers.launchpad.net/sikuli/+question/689241 Status: Answered => Solved xyz_User confirmed that the question is solved: Thanks RaiMan, that solved my question. -- You received this question notification because your team Sikuli Drivers is an answer contact for Sikuli. ___ Mailing list: https://launchpad.net/~sikuli-driver Post to : sikuli-driver@lists.launchpad.net Unsubscribe : https://launchpad.net/~sikuli-driver More help : https://help.launchpad.net/ListHelp
Re: [Sikuli-driver] [Question #689241]: Observer not stopping / causing script to a halt/slugghish execution
Question #689241 on Sikuli changed: https://answers.launchpad.net/sikuli/+question/689241 Status: Solved => Open xyz_User is still having a problem: Thanks very much RaiMan! One more thing to add, is there any way to add a certain area - In the above example: Once it clicked something (since pixel changed), it will keep it in an "avoid list" so that on the next scan it doesn't click into this area again? -- You received this question notification because your team Sikuli Drivers is an answer contact for Sikuli. ___ Mailing list: https://launchpad.net/~sikuli-driver Post to : sikuli-driver@lists.launchpad.net Unsubscribe : https://launchpad.net/~sikuli-driver More help : https://help.launchpad.net/ListHelp
Re: [Sikuli-driver] [Question #689241]: Observer not stopping / causing script to a halt/slugghish execution
Question #689241 on Sikuli changed: https://answers.launchpad.net/sikuli/+question/689241 xyz_User posted a new comment: Or perhaps scan around the changed pixel from observer then call a function to see if it matches an image, if it does call something otherwise back to scan. -- You received this question notification because your team Sikuli Drivers is an answer contact for Sikuli. ___ Mailing list: https://launchpad.net/~sikuli-driver Post to : sikuli-driver@lists.launchpad.net Unsubscribe : https://launchpad.net/~sikuli-driver More help : https://help.launchpad.net/ListHelp
Re: [Sikuli-driver] [Question #689241]: Observer not stopping / causing script to a halt/slugghish execution
Question #689241 on Sikuli changed: https://answers.launchpad.net/sikuli/+question/689241 Status: Open => Solved xyz_User confirmed that the question is solved: This Solved My Problem -- You received this question notification because your team Sikuli Drivers is an answer contact for Sikuli. ___ Mailing list: https://launchpad.net/~sikuli-driver Post to : sikuli-driver@lists.launchpad.net Unsubscribe : https://launchpad.net/~sikuli-driver More help : https://help.launchpad.net/ListHelp
Re: [Sikuli-driver] [Question #689241]: Observer not stopping / causing script to a halt/slugghish execution
Question #689241 on Sikuli changed: https://answers.launchpad.net/sikuli/+question/689241 xyz_User confirmed that the question is solved: Thanks RaiMan, that solved my question. -- You received this question notification because your team Sikuli Drivers is an answer contact for Sikuli. ___ Mailing list: https://launchpad.net/~sikuli-driver Post to : sikuli-driver@lists.launchpad.net Unsubscribe : https://launchpad.net/~sikuli-driver More help : https://help.launchpad.net/ListHelp