Ber*_*and 5 java class keycode awtrobot
通过java机器人类按特殊字母(土耳其语等)我有问题.我有一种按键的方法,可以作为alt + keycode.我无法将一些特殊字母转换为当前键码.那我怎么解决呢 感谢名单
例如:
KeyStroke ks = KeyStroke.getKeyStroke('ö', 0);
System.out.println(ks.getKeyCode());
Output : 246
// So alt+0246='ö'
//but if I convert '?' to keycode
//Output is 351 . So alt+351= '_' and alt+0351= '_'
//What is the Correct combination for '?'. same for '?', '?','?', '?', '?', '?', '?', '?'
Run Code Online (Sandbox Code Playgroud)
按键:
public void altNumpad(int... numpadCodes) {
if (numpadCodes.length == 0) {
return;
}
robot.keyPress(VK_ALT);
for (int NUMPAD_KEY : numpadCodes) {
robot.keyPress(NUMPAD_KEY);
robot.keyRelease(NUMPAD_KEY);
}
robot.keyRelease(VK_ALT);
}
Run Code Online (Sandbox Code Playgroud)
我不确定你为什么这么做
\n\nKeyStroke ks = KeyStroke.getKeyStroke(\'\xc3\xb6\', 0);\nRun Code Online (Sandbox Code Playgroud)\n\n因为java文档说,
\n\npublic static KeyStroke getKeyStroke(Character keyChar,\n int modifiers)\n//Use 0 to specify no modifiers.\nRun Code Online (Sandbox Code Playgroud)\n\n您需要将 0 以外的修饰符传递给重载。
\n\n您应该尝试通过修改,例如,
\n\njava.awt.event.InputEvent.ALT_DOWN_MASK\nRun Code Online (Sandbox Code Playgroud)\n\n所以可能应该尝试,
\n\nKeyStroke ks = KeyStroke.getKeyStroke(\'\xc3\xb6\', java.awt.event.InputEvent.ALT_DOWN_MASK);\nRun Code Online (Sandbox Code Playgroud)\n\nJava文档作为参考:http://docs.oracle.com/javase/7/docs/api/javax/swing/KeyStroke.html#getKeyStroke(char)
\n\n如果您无法正确获得输出,那么您应该考虑该字符是 UTF-8 \n这可能会在这方面帮助您,Java,使用扫描仪将字符输入为 UTF-8,无法打印文本
\n