← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #227960]: How to make sikuli detect motions within a specific region?

 

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

RaiMan proposed the following answer:
Uuups, I did some crap in the above mentioned code - sorry.

this should do it:

Here goes the code snippet which I've tried based on your logic:
(modified ;-)

bigScreenReg = Region(278,155,718,397)
bigScreenReg.highlight(3)
print "Checking bigScreen Video Region"
r = bigScreenReg
r.onChange(100, changed)
Settings.isChanged = False

r.observe(5) # observing for 5 seconds (script pauses here)

if Settings.isChanged: # check wether the handler was called (because there where changes)
    print "there where changes"
else:
    print "there haven't  been any changes"

And the following is the handler:

def changed(event):
    print "something changed in ", event.region
    for ch in event.changes:
        ch.highlight() # highlight all changes
    sleep(1)
    for ch in event.changes:
        ch.highlight() # turn off the highlights
    Settings.isChanged = True
    event.region.stopObserver()


--- comment
You are using the foreground observe in this case, the you should stop the observation in the handler.

hope it helps

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