Question #229825 on Sikuli changed: https://answers.launchpad.net/sikuli/+question/229825
Mark Weisler posted a new comment: The following working code might help you... # script: RegionAreaTest6, 01 June 2013 # Related to [Question #229825]: do an action if the image on a region doesn't change # This Sikuli script monitors a screen area to detect change. bigChange=False # a global variable set if a region changes def changed(event): # this function runs if change is observed print "something changed in ", event.region global bigChange # set to true if this function runs bigChange=True print bigChange for ch in event.changes: ch.highlight(2) # highlight all changes sleep(1) for ch in event.changes: ch.highlight() # turn off the highlights event.region.stopObserver() # now start watching a Chicago Transit Authority map of buses moving down streets # http://ctabustracker.com/bustime/map/displaymap.jsp print "Starting..." myRegion=Region(200,250,500,500) # adjust size of region examined, make area as small as reasonably possible to limit searching, analysis #myRegion=Region(420,270,200,200) # an alternative region that is smaller myRegion.highlight(3) # for illustrative purposes, not functionally necessary wait(1) myRegion.highlight(0) #remove highlight wait(1) print bigChange # value of the variable before starting the monitoring myRegion.onChange(30, changed) # install 'changed' as the function to run if changes are discovered myRegion.observe(30,background=True) # start observing for 30 seconds before proceeding # Monitoring is now running. # Next start a loop to check for changes in the monitored area... myLimit=4 i = 0 # index for our loop mycontinue = True print "Starting mycontinue loop..." while mycontinue: print bigChange if bigChange: print "Something just changed." else: print "No change yet." # Do some desired action here... i +=1 # increment index if i >=myLimit: mycontinue=False wait(5) print "Leaving mycontinue loop..." myRegion.stopObserver() #stops the observer myRegion=Region(100,300,500,500) myRegion.highlight(3) wait(1) print bigChange exit(0) -- You received this question notification because you are a member of Sikuli Drivers, which 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