代码
Robot r=new Robot();
r.keyPress(KeyEvent.VK_CAPS_LOCK);
r.keyPress(KeyEvent.VK_V);
r.keyPress(KeyEvent.VK_CAPS_LOCK);
打印V
后,不会关闭。我该如何解决?
答案 0 :(得分: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);