Hey, using this piece of code:
try {
Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_H);
robot.keyRelease(KeyEvent.VK_H);
robot.keyPress(KeyEvent.VK_A);
robot.keyRelease(KeyEvent.VK_A);
robot.keyPress(KeyEvent.VK_L);
robot.keyRelease(KeyEvent.VK_L);
robot.keyPress(KeyEvent.VK_L);
robot.keyRelease(KeyEvent.VK_L);
robot.keyPress(KeyEvent.VK_O);
robot.keyRelease(KeyEvent.VK_O);
} catch (AWTException e) {
e.printStackTrace();
}
I get this result:
hallo
But is there a way to shorten this process? for example something like:
try {
Robot robot = new Robot();
String word = "hallo";
robot.keyPress(KeyEvent.word);
} catch (AWTException e) {
e.printStackTrace();
}
I know this example does not work, but I could not find documentation about it.
Do you have any ideas? greetings and thanks
source
share