[1.1.0] observe: Handler Type test

Asked by Tetsuo

Hi. In the OnVanish and OnAppear handle how im able to test what is the type of event that happened on the screen.

def myhandle(event):
        if event.type == "VANISH":
        if event.type == "APPEAR":

does not work. Sorry if its a basic question. Im new to all of this.

Thanks

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
Tetsuo
Solved:
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

if we are talking about 1.1.0:

type = event.getType()

the possible types you might get (depending on the used onXXX):

if type == ObserveEvent.VANISH:

.... .APPEAR
.... .CHANGE

come back if it is not 1.1.0

(I will update the docs for 1.1.0 on monday)

Revision history for this message
Tetsuo (tetsuo-rti) said :
#2

Humm..sorry if its to obvious, but what is ObserveEvent?
I thought the handler receives SikuliEvent as a parameter.

Also,

event.getType() does not seen to work. Here is my code

def MyHandler(event):

        print event.type #prints VANISH
        event_type = event.getType()
        print event_type #prints nothing.

         if event.type == ObserveEvent.VANISH
                       print xxxx #prints nothing

Thanks.

Revision history for this message
Tetsuo (tetsuo-rti) said :
#3

Im using 1.10 btw. Thanks.

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

Sorry for misleading you --- was more hope than reality ;-)

I have still to implement getType() and of course update the docs.
You then will be able to say besides getType() returning a string:
isAppear(), isVanish(), isChange() returning True or False
I will do that as soon as possible.

Watch out on the nightly build page for a fix:
added: observe handler: getType()

For now, this is possible:

if str(e.type) == "APPEAR":

same for "VANISH", "CHANGE" and "GENERIC" (mouse moved handler)

Revision history for this message
Tetsuo (tetsuo-rti) said :
#5

Thanks RaiMan.
Ill keep an eye on the nightly build page and will use your solution for now.