Event hadling doesnot loop

Asked by Shivakumar

Hello Raiman,
I am Shivakumar, I am new to this Forum and Sikuli.
I am trying to use the Event handler and it seems to work in a differnt way, below is what I am trying to do.
The objective is before I start a new test I would like to Close all the Errors and warning window that are visible on the application Screen.

#this defination is to click on the error or the warning Icon and hit enter to Close it, I use hit enter as it is the OK button always that is selected by Default.

def clickenter(errororwarning):
    print errororwarning
    print "entering def"
    if exists(errororwarning):
        print "found"
        click(errororwarning)
        wait(1)
        type(Key.ENTER)
        wait(1)

 #on appear of the error, I call the defination clickenter with a Parameter of error image
 onAppear(imagelibrary.ERROR, clickenter(magelibrary.ERROR))

 #on appear of the error, I call the defination clickenter with a Parameter of warning image
onAppear(magelibrary.Warning, clickenter(magelibrary.Warning))

#Keep a Observation for 10 seconds
observe(10)

The Problem that happens is I have a 2 to 3 warning Images, with the above code it only calls the def ones and Close only the first warning popup window, after the Close there is another warning window but it doesnot go in the def again, isnt it the "observe" should Keep Looping for 10 seconds ? or Am I doing some thing wrong.?

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
Best RaiMan (raimund-hocke) said :
#1

not the intended use:

clickenter is a callback, that is called in case the defining event (onWhatever()) happens

so this is correct:
onAppear(imagelibrary.ERROR, clickenter)

your usage calls clickenter in the moment the onAppear is processed, which is surely not what you want.

So you have to completely revise your usage of observe based on the docs.
Be sure to use SikuliX version 1.1.0+

Revision history for this message
Shivakumar (prostep-sawarge) said :
#2

Hello Raiman,
Yes, my assumption was wrong, the Images that I am passing to the clickenter def were already existing on the Screen, and they do not appear, so there is no Event Happening actually. So the Event function works as expected, I will try to Change the logic so that fit my requirement work.

Thank You very much for your Support and time.

Regards
Shiva