0

编码

Robot r=new Robot();
r.keyPress(KeyEvent.VK_CAPS_LOCK);
r.keyPress(KeyEvent.VK_V);
r.keyPress(KeyEvent.VK_CAPS_LOCK);

打印后不关闭V。我该如何解决?

4

1 回答 1

3

您必须在按下按键后释放按键:

Robot r=new Robot();
r.keyPress(KeyEvent.VK_CAPS_LOCK);
r.keyRelease(KeyEvent.VK_CAPS_LOCK);
r.keyPress(KeyEvent.VK_V);
r.keyRelease(KeyEvent.VK_V);
r.keyPress(KeyEvent.VK_CAPS_LOCK);
r.keyRelease(KeyEvent.VK_CAPS_LOCK);
于 2013-04-28T12:18:03.273 回答