I'm trying to automate some processes using Robot
and it seems certain keycodes (only symbols that require you to hold shift when typing it normally) in KeyEvent
are throwing an IllegalArgumentException
. This is all the code that's running in main
:
Robot r = new Robot();
r.keyPress(KeyEvent.VK_EXCLAMATION_MARK);
However, it works fine using the following workaround:
Robot r = new Robot();
r.keyPress(KeyEvent.VK_SHIFT);
r.keyPress(KeyEvent.VK_1);
Any ideas why the exception is thrown? Thanks!
Java version: 1.6.0_23