java.awt.Robot on windows
843807Dec 8 2008 — edited Jan 27 2009Hello,
I'm having problems with the Robot class when trying to simulate SHIFT+ARROW_LEFT (or any other cursor key) on windows. Things are working fine on linux when I run this code:
Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_SHIFT);
robot.keyPress(KeyEvent.VK_RIGHT);
robot.keyRelease(KeyEvent.VK_RIGHT);
robot.keyRelease(KeyEvent.VK_SHIFT);
The character left to the cursor gets selected. But this code doesn't work on windows. The cursor is moved one character to the left, but nothing is selected. I made a keyboard event listener and according to it it looks like if the SHIFT key is released before the arrow key is pressed. Here is the output of the event listener.
DOWN keyCode:131072 stateMask:0
UP keyCode:131072 stateMask:131072
DOWN keyCode:16777220 stateMask:0
UP keyCode:16777220 stateMask:0
DOWN keyCode:131072 stateMask:0
UP keyCode:131072 stateMask:131072
Could someone please explain what is happening? Why is windows releasing the SHIFT key before pressing the VK_RIGHT? On linux this is not happening.
In case you are wondering... I ma making some macros for the IDE.
Thanks
Toba