我有一个 java 机器人来输入字符,但是它打印的内容如下:
.. 5./. .. .. //5 / /55/ /.. ..5.. .. 5 5 . 5.
而不是想要的字符串。有人知道如何避免这种情况吗?
import java.awt.Robot;
import java.awt.AWTException;
Robot robot;
String txt = "o noes ";
char[] chars;
void setup() {
chars = txt.toCharArray();
try {
robot = new Robot();
}
catch(AWTException e) {
}
robot.setAutoDelay(1);
for (int i = 0; i < 10000; i++) {
int c = chars[(int)random(chars.length)];
robot.keyPress(c);
robot.keyRelease(c);
}
}