robot class key combinations with processing
in
Programming Questions
•
6 months ago
hello, I am trying to send key combinations through my processing program to send out commands to AutoHotkey, such as Control+Shift+Left, Control+Shift+Right.
But the problem is that basically nothing happens with no error: Here is the code below:
- import java.awt.Robot;
- import java.awt.event.KeyEvent;
- Robot robot;
- try { robot = new Robot(); }
- catch (AWTException e) { e.printStackTrace(); }
- //Control+Shift+Right
- robot.keyPress(KeyEvent.VK_CONTROL); robot.keyPress(KeyEvent.VK_SHIFT); robot.keyPress(39);robot.keyRelease(KeyEvent.VK_CONTROL); robot.keyRelease(KeyEvent.VK_SHIFT); robot.keyRelease(39);
- //Control+Shift+Left
- robot.keyPress(KeyEvent.VK_CONTROL);robot.keyPress(KeyEvent.VK_SHIFT);robot.keyPress(37);robot.keyRelease(KeyEvent.VK_CONTROL); robot.keyRelease(KeyEvent.VK_SHIFT);robot.keyRelease(37);
Please Help
Thanks!
1