0

I use the following event to escape a window's pop-up ("This page is ready for print. Would you like to ...") but it seems that the release event doesn't work. Once the test is finished, the keyboard stays locked and I am not able to use it unless I switch the window's user and log in again. The same behavior is observed with other key events (VK_ALT+VK_SPACE+VK_N)

  Robot robot = new Robot();
  robot.keyPress(KeyEvent.VK_ESCAPE);
  robot.delay(5000);
  robot.keyRelease(KeyEvent.VK_ESCAPE);

Thank you in advance for your advices!

3
  • 1
    Please share a complete but minimal reproducible example. Commented Jul 2 at 14:48
  • 1
    Try adding a Thread.sleep after the keyRelease. It could be that the release event is not being dispatched to OS before the VM exits. Try it and check once. Also it will be helpful if you can provide a reproducible example as observed in the above comment
    – Ironluca
    Commented Jul 2 at 16:53
  • @Ironluca - After the keyRelease I had also added robot.delay(5000) which is basically the same (as it includes Thread.sleep) but it didn't help. When I added your suggestion - the problem stopped. Thanks a lot! (You could write an answer, I will accept it)
    – Mr Cas
    Commented Jul 3 at 13:43

0

Browse other questions tagged or ask your own question.