← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #228749]: How Alt+Shift+C works to stop the sikuli

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
The relevant top level code from 
https://github.com/RaiMan/SikuliX-IDE/blob/master/Java/org/sikuli/ide/SikuliIDE.java

lines 2230+

  public void removeStopHotkey(int key, int mod) {
    HotkeyManager.getInstance()._removeHotkey(key, mod);
  }

  public void installStopHotkey(int key, int mod) {
    HotkeyManager.getInstance()._addHotkey(key, mod, new HotkeyListener() {
      @Override
      public void hotkeyPressed(HotkeyEvent e) {
        onStopRunning();
      }
    });
  }

  public void onStopRunning() {
    Debug.log(2, "StopRunning");
    this.setVisible(true);
    _btnRun.stopRunning();
    _btnRunViz.stopRunning();
  }

This global hotkey handling is system dependent and is wrapped in the
class org.sikuli.script.HotkeyManager.

to add your own stop hotkey, this would be sufficient put somewhere in
your code:

HotkeyManager.getInstance()._addHotkey(key, mod, new HotkeyListener() {
  @Override
  public void hotkeyPressed(HotkeyEvent e) {
    // here you have to add your handling code
  }
});

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