JAVA API : hotkey working just first time?

Asked by Dado on 2018-11-09

I'm trying to stop a loop in my app using a global hotkey .
This is the code for the hotkey I'm using:

        HotkeyListener hk_CTRL_F1 = new HotkeyListener()
            public void hotkeyPressed(HotkeyEvent e) {

        HotkeyManager.getInstance().addHotkey(Key.F1, KeyModifier.CTRL, hk_CTRL_F1 );

then in my loop I'ìm checking for running==true, else it should end.
I'm running my app from intellij IDEA ide, it works fine the fisrt time, then if I run it again the hotkey is not working anymore and the loop goes on forever.

if I close the IDE , repon and start it again , the hotkey works fine again (the first time).

I tried also to remove the hotkey after the loop, before closing the app like this:


but this does not help.

Any idea? is it a bug?


Question information

English Edit question
Sikuli Edit question
No assignee Edit question
Last query:
Last reply:
RaiMan (raimund-hocke) said : #1

Offline til Nov 20th
Surely not the intended use
You have to wait or find out

masuo (masuo-ohara) said : #2


Variable "running" is global ?
By popup window you can confirm hotkey is available .

This code works as expected.
[example as python:]
flag = True
def handler(event):
    global flag
    flag = False


while True:
    if flag == False:

Dado (dadotc) said : #3

hi masuo, thanks, yes the variable is global, and I'm sure the hotkey is available because sometimes it works.
I'll do some more test to try understand what could be

Can you help with this problem?

Provide an answer of your own, or ask Dado for more information if necessary.

To post a message you must log in.