code exits

Asked by erdemalkan

Hello,
I hope someone help me on this situation. This is my code it works only one time when onAppear happens calls darker event after event finished, Code exit. It dosent wait onAppear again. I am noob with phyton i hope some one help me about this.
Best regards

def darker(event):
        find("1369324585799.png")
        click("1369323823739.png")
        if exists("1369327017989.png"):
            click("1369324124167.png")
        else:
            click("1369326919620.png")

onAppear("1369323286214.png", darker)
observe(FOREVER)

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

an observe(FOREVER) always finishes after the match. It does not "loop" internally.
The script is paused at that point, until the observe finishes.

only a background observe.
observe(FOREVER, true)

will continuously check for appearance and call the handler.
the script continues after the observe (and hence in your case would end also (but the observer in the background will continue until the IDE is stopped (or more generally the parent JVM).

Revision history for this message
erdemalkan (erdem-alkan) said :
#2

i used observe(FOREVER,True) as u said code ran backgroud and exit again after first handler finished. Any setting should i have to make or can you give me simple example that runs code start over again. Because ' couldnt ran my code again after first call

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

sorry, on vacations until June 10th

Revision history for this message
erdemalkan (erdem-alkan) said :
#4

Thanks RaiMan, that solved my question.