← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #269618]: Error when running more than one script using hotkeys.

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
# define the action for hotkey ctrl-shift-F1
def runMySikuliScriptA(event):
    runScript("C:\Sikuli\Scripts\MySikuliScriptA")
Env.addHotkey(Key.F1, KeyModifier.CTRL+KeyModifier.SHIFT, runMySikuliScriptA)

# define the action for hotkey ctrl-shift-F2
def runMySikuliScriptB(event):
    runScript("C:\Sikuli\Scripts\MySikuliScriptB")
Env.addHotkey(Key.F2, KeyModifier.CTRL+KeyModifier.SHIFT, runMySikuliScriptB)

# define hotkey ctrl-shift-F3 to stop the script
def runMySikuliScriptB(event):
    global shouldStop
    shouldStop = True
Env.addHotkey(Key.F3, KeyModifier.CTRL+KeyModifier.SHIFT, runMySikuliScriptB)

# keep the script running, to wait for the hotkeys to be pressed
shouldStop = False
while not shouldStop:
    wait(1)

Since you had the infinite wait loop before definition of F2, it was not
processed.

After aborting the scriptrun, you get the normal Java reaction, when
aborting something, that simply waits.

The above solution allows to stop the script gracefully.

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