← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #204038]: need simple lock code to keep event handler in line

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
I think, this is not the whole story, since this does not prevent the
popup to arise in parallel with the swipe action, which is the real
problem: it gets to foreground and accepts the swipe action and the
content goes to the clipboard.

I think you have to check, wether the popup arises during this sequence
and decide to reset and repeat the swipe action.

Your current locking prevents the swiping, if the handler is already
active. But if the swipe has locked and started, the shit might happen
any way and on top blocks the handler to do its job.

I would not use the locking feature, but something like this:

first the handler:

def ClickOK(event):
    Settings.myInHandler = True
    event.region.click("Error.png") # clicks the ok button on the pop up
    wait(0.5)
    Settings.myInHandler = False

def swipe(begin,end):
    while True:
        while Settings.myInHandler: wait(0.5)
        mouseDown(begin, Button.LEFT)
        if Settings.myInHandler: continue
        mouseMove(end)
        if Settings.myInHandler: continue
        mouseUp()
        if Settings.myInHandler: continue
        type("c",KEY_CTRL)
        wait(0.5)
        if Settings.myInHandler: continue
        break   # if we finally come here, it should have worked.

I have broken the dragDrop into the 3 mouse actions to get more
checkpoints in between.

Somewhere at the beginning you have to say:
Settings.myInHandler = False

the 2 wait()'s have to be adjusted accordingly, to get some overlapping
for robustness.

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