Am working on a robot engine which will do/key press of all the keys present in the keyboard to a notepad. i.e by using
robot.keyPress(KeyEvent.VK_A);
robot.keyRelease(KeyEvent.VK_A);
So on as the possibility is present in KeyEvent which is ascii.
Now if I change the Keyboard layout say to Italy, if I type/press square BracketLeft & BracketRight its should print or type è & *, respectively. These are unicode characters, its not helping. As per the API of KeyEvent it supports ASCII. So Unicode cannot be called.
KeyStroke ks = KeyStroke.getKeyStroke(chars[t], 0);
//Where chars is the array storing unicode characters
System.out.println(ks.getKeyCode());
Above one tried using ALT+ks.getKeyCode(), but this too in vain. This I tried as per the suggestion given in here stackoverflow
1) Now I am thinking is it possible to read as rows & columns the keys from Keyboard in java & I can start playing/working with it ? Is yes, how can I do it ? Which API ?
Or 2) Is there any other way to perform the keyPress Event for Unicode Characters using Java (Robot)?
or 3) any other medium to pefrom keyPress into a notepad for different Keyboard layouts.
All this I am trying on Java 1.6 & Java 1.8.
Looking for your valuable suggestion.
char []c = {'è','é','+','*','ù','§','ò','ç','à','°','.',':','-','_'};
performKeyStroke(c);`
private void performKeyStroke(char []chars){
int charLeng = null == chars ?0:chars.length;
for(int t=0;t<charLeng;t++){
System.out.println("trying for --->"+chars[t]);
KeyStroke ks = KeyStroke.getKeyStroke(chars[t], 0);
System.out.println(ks.getKeyCode());
pressCombinationKeys(String.valueOf(ks.getKeyCode()));
}//End of for loop
}//End of performKeyStroke
private void pressCombinationKeys(String nums){
this.robot.keyPress( KeyEvent.VK_ALT );
// -- have to apply some logic to know what sequence
this.keyPressRelease( KeyEvent.VK_0 );
int numLength = null == nums?0:nums.length();
try{
for(int u=0;u<numLength;u++){
this.keyPressRelease(Integer.valueOf(nums.charAt(u)));
System.out.print(nums.charAt(u));
}//End of for loop
}catch(Exception e){
e.printStackTrace();
}
this.robot.keyRelease( KeyEvent.VK_ALT );
}//End of pressCombinationKeys
Thanks in Advance This is something similar which I asked here