Using onAppear

Asked by Mark McGuinn

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:
Expired
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
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))

Revision history for this message
Launchpad Janitor (janitor) said :
#2

This question was expired because it remained in the 'Open' state without activity for the last 15 days.