How Alt+Shift+C works to stop the sikuli

Asked by Uwin Adri

Hi there everyone!
I am developing a Java application using sikuli. Does anyone know how the Alt+Shift+C mechanism works? My application once running, it's GUI goes background. And I would like have a way to stop it whenever I want like it's done in the Sikuli IDE.
I've downloaded the sources of the Sikuli IDE from RaiMan's github account. You might tell me in which class it's done.
Thanks for your help!
kindly.

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
Best RaiMan (raimund-hocke) said :
#1

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
  }
});

Revision history for this message
Uwin Adri (auwindekwe) said :
#2

Thanks RaiMan, that solved my question.