← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #243614]: Observe on Change event exits script or brings up IDE and continues running

 

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

RaiMan posted a new comment:
This is a simple alternative, to watch changes in one region and do
something when it changes:

# define the region to observe
# find your solution
r = find("1392145650656.png").grow(300)
r.highlight(2)

# called when region changes
# this is your worker (the handler with observe)
def doSomething():
    print "has changed"
    wait(2)

# capture the first content
img = capture(r)
max = 5

while max > 0: # for testing
#while True: # for real running 
    wait(1) # defines the observe scan rate
    if not r.exists(img,0):
        doSomething()
        # capture the content to watch for change
        img = capture(r)
        max -= 1

# the script can be stopped using shift-alt-c

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.