← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #194235]: Limitations of Env.addHotkey ?

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
--- hotkey using special characters
I confirm this for Windows: only letters and numbers can be used
On Mac this seem to work though.

--- odd behavior inside hotkey handler when using mouse/keyboard actions
I confirm this for Windows too.
When using type and click in a handler, it seems, that each hotkey action has to be terminated by a real keyboard or mouse action (means: done manually by the user), to get the hotkey handler into a state, that hot keys are accepted and/or the scripted handler actions are done correctly.

example script used:

def handler(e):
    print "in handler"
    hover(getCenter())
    wait(2)
    click(Env.getMouseLocation())
    type("in handler", KeyModifier.SHIFT)
    type(Key.ENTER)
    wait(1)
    m = find("1335247813409.png")
    doubleClick(m.below(100))
    click(m.below(100))

def stoppit(e):
    global isStopped
    isStopped = True
    print "in stoppit"
    return
    
isStopped = False
Env.addHotkey("m", KeyModifier.ALT + KeyModifier.CTRL, handler)
Env.addHotkey("x", KeyModifier.ALT + KeyModifier.CTRL, stoppit)

while not isStopped:
    wait(1)

exit()

There is a notepad window open, so the center click gives focus to that
window.

ctrl+alt+m works the first time after starting the script. When repeating it, there is no reaction.
After pressing a real key or the real mouse, the hotkey is again accepted and does what it should do.

I think, this can be called a bug.

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