[1.0.1] observe region not working --- specify observe time in any case (bug)

Asked by Muhammad Ammar

Hi,

I am using the below script to see how observe is working with onChange. I am observing skpe chat window and want to open a popup a message if i receive a message in skype chat window. But this is not working. Am i selecting the region incorrectly? What is the correct way to select the region?

I am a newbie, please help

def changed(event):
        popup('something changed')
        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
with selectRegion("select a region to observe") as r:
    # any change in r larger than 50 pixels would trigger the changed function
    onChange(50, changed)
    observe(background=True)

wait(30) # another way to observe for 30 seconds
r.stopObserver()

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

what version of Sikuli, what system?

Revision history for this message
Muhammad Ammar (mammar) said :
#2

sikuli version: 1.0.1
OS: Fedora 18 64bit

Revision history for this message
Best RaiMan (raimund-hocke) said :
#3

There is a bug with observe(background=True) in 1.0.1:
In any case you have to give a time value, because otherwise the observe does not start at all.
To observe forever, just use a large value like 24*60*60 or the constant FOREVER.

Revision history for this message
Muhammad Ammar (mammar) said :
#4

Thanks RaiMan, that solved my question.

Revision history for this message
Muhammad Ammar (mammar) said :
#5

Great Thanks RaiMan for help and responding quickly.