Detecting screen changes in a region

Asked by arminius on 2017-11-17

    while True:
    bigScreenReg = Region(1242,57,123,640)
    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)
        popup('there have been changes')
        print "there haven't been any changes"

It seems to be highlighting when there are changes in the region, but the popup never get's activated, the log just forever is filled with "there haven't been any changes" even though there were definitely changes in the region that I observed.

Basically I just want it to throw a popup when there are changes in the region.

Question information

English Edit question
Sikuli Edit question
No assignee Edit question
Solved by:
Last query:
Last reply:
masuo (masuo-ohara) said : #1

"Settings.isChanged" is your own variable?

Now, Settings.isChanged is set False in your codes and Settings.isChanged is not modified anywhere.

You have to add code in function "changed" to modify the value of Settings.isChanged to True.

arminius (arminius75) said : #2

not my variable, I found it on a google search and tried to get it to work, but found this one way easier.

    def changeHandler(event):
        event.region.somethingChanged = True
    while True:
        nav = Region(129,59,221,266)
        nav.somethingChanged = False
        if nav.somethingChanged:
            print "changed within observation time"
            popup('changed within observation time')
        if not nav.somethingChanged:
            print "did not change within observation time"