+ * Command to type a string
+ */
+ private static class TypeCommand implements MonkeyCommand {
+ // wake
+ public MonkeyEvent translateCommand(List<String> command,
+ CommandQueue queue) {
+ if (command.size() == 2) {
+ String str = command.get(1);
+
+ char[] chars = str.toString().toCharArray();
+
+ // Convert the string to an array of KeyEvent's for
+ // the built in keymap.
+ KeyCharacterMap keyCharacterMap = KeyCharacterMap.
+ load(KeyCharacterMap.BUILT_IN_KEYBOARD);
+ KeyEvent[] events = keyCharacterMap.getEvents(chars);
+
+ // enqueue all the events we just got.
+ for (KeyEvent event : events) {
+ queue.enqueueEvent(new MonkeyKeyEvent(event));
+ }
+ return new MonkeyNoopEvent();
+ }
+ return null;
+ }
+ }
+
+ /**