S
Sameer
Hello,
How to map character from a string to the corresponding
KeyEvent.VK_character?
I want to generate events to type a sentence.
Do I need to enter the corresponding integer constants in an array and
use it? Can it be simplified?
import java.awt.event.*;
import java.awt.*;
public class RobotDemo {
String string2Print;
RobotDemo(String str) {
string2Print=str;
char[] charArray=string2Print.toCharArray();
try {
Robot rob = new Robot();
for (int i = 0; i < charArray.length; i++) {
// CODE NEEDED HERE
rob.delay(1000);
}
rob.keyPress(KeyEvent.VK_ENTER);
}catch (AWTException awte) {
}
}
public static void main(String args[]) {
new RobotDemo("TESTING");
}
}
I even tried to put the KeyEvent.VK_... constant in a Hashtable as
ht.put("A", KeyEvent.VK_A)
but I was unable to retrieve the constant and use it for event.
I need generelised code which maps a character to corresponding
constant if possible.
Please help.
-Sameer
How to map character from a string to the corresponding
KeyEvent.VK_character?
I want to generate events to type a sentence.
Do I need to enter the corresponding integer constants in an array and
use it? Can it be simplified?
import java.awt.event.*;
import java.awt.*;
public class RobotDemo {
String string2Print;
RobotDemo(String str) {
string2Print=str;
char[] charArray=string2Print.toCharArray();
try {
Robot rob = new Robot();
for (int i = 0; i < charArray.length; i++) {
// CODE NEEDED HERE
rob.delay(1000);
}
rob.keyPress(KeyEvent.VK_ENTER);
}catch (AWTException awte) {
}
}
public static void main(String args[]) {
new RobotDemo("TESTING");
}
}
I even tried to put the KeyEvent.VK_... constant in a Hashtable as
ht.put("A", KeyEvent.VK_A)
but I was unable to retrieve the constant and use it for event.
I need generelised code which maps a character to corresponding
constant if possible.
Please help.
-Sameer