2014-12-04 91 views
0

我有通過java機器人類按特殊字母(中文,西里爾文等)的問題。我有一種方法來按鍵作爲alt +鍵碼。我不能將一些特殊字母轉換爲corrent keycode。那我該如何解決它。感謝名單Java機器人課堂按特別信?

例如:

 KeyStroke ks = KeyStroke.getKeyStroke('a', 0); 
    System.out.println(ks.getKeyCode()); 
    Output : 97 
    //but if I convert 'ş' to keycode 
    //Output is 351 . So alt+351= '_' The Correct combination is alt+0254 for 'ş' 

按鍵:

public static void doType(int a, int keyCodes) 
     throws AWTException { 
    Robot robot = new Robot(); 
    robot.keyPress(VK_ALT); 
    robot.keyPress(keyCodes); 
    robot.keyRelease(keyCodes); 
    robot.keyRelease(VK_ALT); 
} 

回答

2

'A' 的計算結果爲97 UTF-8

KeyStroke.getKeyCode() 

只是返回'a'的整數表示形式。

+0

http://stackoverflow.com/questions/397113/how-to-make-the-java-awt-robot-type-unicode-characters-is-it-possible – 2014-12-04 19:54:23