I'm working on a system to type things automatically with java. This is how I write it:
public void typeMessage(String message) {
for (char c : message.toCharArray()) {
int code = c;
if (code > 96 && code < 123)
code = code - 32;
if (c == '@') {
robot.keyPress(VK_SHIFT);
robot.keyPress(VK_AT);
robot.keyRelease(VK_SHIFT);
robot.keyRelease(VK_AT);
} else {
type(code);
}
}
type(VK_ENTER);
}
But I'm getting this error:
Exception in thread "Thread-2" java.lang.IllegalArgumentException: Invalid key code
on
robot.keyPress(VK_AT);
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…