2014-12-04 8 views
0

자바 로봇 클래스를 통해 특수 문자 (중국어, 키릴 문자 등)를 누르는 데 문제가 있습니다. 나는 alt + keycode로 작동하는 키를 누르는 방법을 제안합니다. 일부 특수 문자를 corrent 키 코드로 변환 할 수 없습니다. 어떻게 해결할 수 있을까요?자바 로봇 클래스 프레스 특수 문자?

 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

'는'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 –