I already know how to use java.awt.Robot to type a single character using keyPress, as seen below. How can I simply enter a whole
This doesn't type the entire "string" but helps to type whatever you want other than one character at a time.
Runtime.getRuntime().exec("notepad.exe");//or anywhere you want.
Thread.sleep(5000);//not required though gives a good feel.
Robot r=new Robot();
String a="Hi My name is Whatever you want to say.";
char c;
int d=a.length(),e=0,f=0;
while(e<=d)
{
c=a.charAt(e);
f=(int) c; //converts character to Unicode.
r.keyPress(KeyEvent.getExtendedKeyCodeForChar(f));
e++;
Thread.sleep(150);
}
see it works perfectly and it's awesome! Though it doesn't work for special characters which cannot be traced by unicode like |,!...etc.