So if to run code below and press registered hotkey always first time Alt + Key work as expected without any delay nothing, if to close program and run again the same thing always first time work as expected, second third etc times not. This look like first time the HotKey event is started when Alt key is released this is why all work okay all others time need the delay until Alt key is released. Is there any way to fix this ?
- Code: Select all
public void k(){
JIntellitype.getInstance().registerHotKey(1, JIntellitype.MOD_ALT, (int)'D');
JIntellitype.getInstance().registerHotKey(2, JIntellitype.MOD_ALT, (int)'J');
JIntellitype.getInstance().registerHotKey(3, JIntellitype.MOD_ALT, (int)'K');
JIntellitype.getInstance().addHotKeyListener(new HotkeyListener() {
public void onHotKey(int aIdentifier) {
if (aIdentifier == 1) {
System.out.println("WINDOWS+W hotkey pressed");
new Thread(new Runnable() {
@Override
public void run() {
new L();{ghostWalk();}
}
}).start();
}
}
});
}
//
//
public void ghostWalk(){
Robot robot = null;
try {
robot = new Robot();
//robot.setAutoWaitForIdle(true);
//robot.delay(60); //60
robot.keyPress(KeyEvent.VK_Q);
robot.keyRelease(KeyEvent.VK_Q);
robot.keyPress(KeyEvent.VK_Q);
robot.keyRelease(KeyEvent.VK_Q);
robot.keyPress(KeyEvent.VK_W);
robot.keyRelease(KeyEvent.VK_W);
robot.keyPress(KeyEvent.VK_R);
robot.keyRelease(KeyEvent.VK_R);
robot.delay(i);
robot.keyPress(KeyEvent.VK_D);
robot.keyRelease(KeyEvent.VK_D);
} catch (Exception e) {
e.printStackTrace();
}
}