【发布时间】:2014-03-02 00:23:32
【问题描述】:
这个错误已经存在多年,但仍然存在于我在 Windows 8 上使用的 Java 1.7.0_25 版本中。无论我是否打开了数字锁定,以下结果都是相同的:
Robot bot = new Robot();
bot.keyPress(KeyEvent.VK_UP); //this in documentation is non-numpad up arrow key
bot.keyRelease(KeyEvent.VK_UP); //pressed the numpad up arrow key
//folowing line is line #43
bot.keyPress(KeyEvent.VK_KP_UP); //this in documentation is numpad up arrow key
bot.keyRelease(KeyEvent.VK_KP_UP); //causes folowing exception:
Exception in thread "main" java.lang.IllegalArgumentException: Invalid key code
at sun.awt.windows.WRobotPeer.keyPress(Native Method)
at java.awt.Robot.keyPress(Robot.java:358)
at test.RobotArrow.main(RobotArrow.java:43)
我知道这个问题已经被问过here,但是一年多以前,有什么进展吗?我不能谷歌任何东西,甚至有一个ofiicial bug report
那么,到底有没有解决办法?
【问题讨论】:
标签: java awt keypress awtrobot arrow-keys