I am experimenting to read a Java source file and write it (to Notepad).
But I don't know how to write simbols like: {,},(,),=,;,. ... and operators like +,-,* and so on.
This is the starting point I am using:
private static void writeString(String str) throws Exception {
// Create instance of Robot class
Robot robot = new Robot();
// Press keys using robot
for (int i = 0; i < str.length(); i++) {
try {
// Check if the current character is a capital letter
if (Character.isUpperCase(str.charAt(i))) {
// Press shift key
robot.keyPress(KeyEvent.VK_SHIFT);
// Press the current character
robot.keyPress(Character.toUpperCase(str.charAt(i)));
// Release shift key
robot.keyRelease(KeyEvent.VK_SHIFT);
} else {
// else display the character as it is
robot.keyPress(Character.toUpperCase(str.charAt(i)));
}
} catch (Exception ignored) {
// Se ignora
}
// wait for 200ms
sleep(200);
}
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
}