When using Robot class, what is the meaning of:
robot.keyRelease(KeyEvent.VK_CONTROL);
Shouldn’t the code below be sufficient to send the event?
Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_CONTROL);
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
keyPresswill send an event that a key has been pressed down.keyReleasewill send the event that the key has been released. If you want to simulate typing, you might want to do something like:Note that to type something with a mask, like Ctrl+A, we first press down Ctrl, then simulate pressing and releasing A, then release Ctrl. As a general rule, the robot should more-or-less exactly simulate what you as a user would do.