2
我正在使用此方法尝试将我的字母输入到表单中。尽管当字符被转换回字符时,它们不会被大写。将特定字母大写的最有效方法是什么?Java使用机器人输出字母(大写和非大写)
我尝试:
private static void type(String s) throws AWTException
{
Robot bot = new Robot();
byte[] bytes = s.getBytes();
for (byte b : bytes)
{
int code = b;
try
{
if (code > 96 && code < 123)
code = code - 32;
bot.delay(40);
bot.keyPress(code);
bot.keyRelease(code);
}
catch(Exception e)
{
System.out.println("Could not read code: " + code + ". Report this to MrGermanrain!");
}
}
}
这并没有工作,因为它只是写小写。
谢谢,伙计!很简单的解决方案我会去争取一下。 –