Using onAppear

Asked by Mark McGuinn on 2019-12-01

In version 2.0.1 I am trying to use the onAppear function to catch when a specific piece of text appears. Below is the code I am using, it simple click a button which causes the image to change. The expected image is within five clicks of the button but the onAppear does not see it and the next click happens which takes away the text I am looking for.I have trued passing the text as a constant, as a variable and as shown in the code as an image. None worked.

def changed(event):
    print("Found It")

regmake.onAppear( "1575203969807.png",changed)

for step in range(5):
    click(Pattern("1575203845288.png").targetOffset(250,123)

Question information

Language:
English Edit question
Status:
Open
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Last query:
2019-12-01
Last reply:
Mark McGuinn (mmcguinn) said : #1

I have been experimenting with this and despite using the IDE tool to define a region I am getting the following in the error messages:

error] Region: observe: Nothing to observe (Region might be invalid): R[541,309 597x407]@S(0)

This is the code I am currently using, am I doing something wrong with the way I am calling this function?

modelarea = Region(541,309,597,407)

# while not (findWord(modelname) or findWord("ANY")):
print modelname

def changed(event):
    print("Found It")
    modelarea.stopobserver()

modelarea.observe(10)

modelarea.onAppear( "1575203969807.png",changed)

for step in range(5):
    click(Pattern("1575203845288.png").targetOffset(250,123))

Can you help with this problem?

Provide an answer of your own, or ask Mark McGuinn for more information if necessary.

To post a message you must log in.