Guys,
I'm writing a little swing app to ease some of my typing chores on my PC. I want to be able to use the Robot interface to automatically type sentences on the screen using KeyEvents. This works perfectly, to the wonder and amazement of my friends and family!
One snag: I can't get it to type a colon.
When I execute the code:
robot.keyPress(java.awt.event.KeyEvent.VK_SHIFT);
robot.keyPress(java.awt.event.KeyEvent.VK_COLON);
robot.delay(10);
robot.keyRelease(java.awt.event.KeyEvent.VK_COLON);
robot.delay(10);
robot.keyRelease(java.awt.event.KeyEvent.VK_SHIFT);
robot.delay(10);
I get the following error:
java.lang.IllegalArgumentException: Invalid key code
at sun.awt.windows.WRobotPeer.keyPress(Native Method)
at java.awt.Robot.keyPress(Robot.java:222)
I can't figure out why VK_COLON is coming up invalid. It should be a valid KeyEvent. According to all the docs (http://java.sun.com/j2se/1.4.2/docs/api/java/awt/event/KeyEvent.html) it's a valid constant.
What do I do next?
Thanks!
chewy