I want to wait until the picture in a region changes

Asked by Aydın on 2021-01-21

region(0,0,400,500), Let's define a region like

When a change is detected in this area, the screen should write "changed".

How can I do that? I have no idea how to do this.

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
Aydın
Solved:
Last query:
Last reply:
Revision history for this message
masuo (masuo-ohara) said :
#1

There is "Quick search" in document page as a way to find a solution.
https://sikulix-2014.readthedocs.io/en/latest/#

Search by "change" , you will find the following page.

"Observing Visual Events in a Region"
https://sikulix-2014.readthedocs.io/en/latest/region.html?highlight=change#observing-visual-events-in-a-region

I think the features introduced here will be useful.

Revision history for this message
Aydın (adn72) said :
#2

thanks, I think this code

 # ******************************
reg= Region(870,227,570,442)

def onchangedFunction(event):
            click(Location(373, 761))

Settings.ObserveScanRate = 10
reg.onChange(50,onchangedFunction)
reg.observe(10,background=False)
reg.stopObserver()
# *****************************

looks like it will
I will return after I do the trials :)

Revision history for this message
Aydın (adn72) said :
#3

The image in the area I determined on the screen changes once, but the application says it has changed 2 times.

Why is this happening?
I don't want to raise the wait() because it slows down my transactions.

My Code Image
https://ibb.co/LncDJ3s

MY CODE
#*********************************
reg= (Region(872,141,579,242))

def changed():
    print "changed"

def notchanged():
    print "notchanged"

def onchangedFunction(event):
    wait(0.5)
    event.getRegion().stopObserver()
    #event.stopObserver()

reg.onChange(50,onchangedFunction)

for x in range(2):
        click(Location(371, 765))
        status = reg.observe(1,background=False)
        print "status = ",status
#*********************************

Revision history for this message
Aydın (adn72) said :
#4

output of my code

[log] CLICK on L[371,765]@S(0) (527 msec)
status = True
[log] CLICK on L[371,765]@S(0) (23 msec)
status = True

but it should be like this

[log] CLICK on L[371,765]@S(0) (527 msec)
status = True
[log] CLICK on L[371,765]@S(0) (23 msec)
status = False

Revision history for this message
masuo (masuo-ohara) said :
#5

I'm sorry, I can comment on the features, but not on the flow.

Revision history for this message
Aydın (adn72) said :
#6

I will consider another alternative solution.

Thank you for the help, Have a nice days