← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #229966]: Checking for sequntial visual events using Observe

 

Question #229966 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/229966

    Status: Needs information => Open

Sanjay gave more information on the question:
Hi j(j-the-k),
Thanks for taking your time to help me with my problem.
I have modified the code as below, now i have only one observe running ,but the handlers are not able to handle all the events, I am missing some events on a regular basis, so i have totally discarded the events and just waiting for the images to appear in a while loop ,which seems to do the job pretty good so far

with searchRegion:
            onAppear(Pattern("UnsuccesfullSend.png").similar(0.9),_checkForStatusChange_unsent)
            onAppear(Pattern("SuccesfuSent.png").similar(0.9),_checkForStatusChange_Sent)
           #onAppear(Pattern("SendingMessage.png").similar(0.9),_checkForStatusChange_sending)
            onAppear(Pattern("MacroError.PNG").similar(0.9),_checkForUnknownErrors)
          #onChange(75,_onChange)
           observe(FOREVER,background=False)

And my handler are like this

def _checkForStatusChange_sending(event):
    #print "Yes Found it"
    print "in _checkForStatusChange_sending"
    tblog.infoLog( "in _checkForStatusChange_sending")
    print event.pattern
    event.region.highlight(1)
    if event.pattern == "SendingMessage.png":
        print "SENDING_FLAG = True"
        global SENDING_FLAG 
        SENDING_FLAG = True
        #print SENDING_FLAG
        #event.region.stopObserver() # stops the observation
def _checkForStatusChange_Sent(event):
    
    #event.region.highlight(1)
    print event.pattern
    match = event.match
    print match
    cp = match.getTopLeft().offset(10,10) # select a pixel, that has the background color
    .......................................
    Some Logging stuff
    .......................................
    event.region.stopObserver() # stops the observation
        
def _checkForStatusChange_unsent(event):
    
    #print event.pattern
    #event.region.highlight(1)
    match = event.match
    print match
    cp = match.getTopLeft().offset(10,10) # select a pixel, that has the background color
    ......................................
    SOME LOGGING
    ......................................
    event.region.stopObserver() # stops the observation

def _checkForUnknownErrors(event):
    #if exists(event.pattern):
    print "in _checkForUnknownErrors"
    #print event.pattern
    tblog.errorLog("Unknown Error")
    global UNKNOWN_ERROR
    UNKNOWN_ERROR = True
    event.region.stopObserver() # stops the observation
    
#    print event.match

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.