Robot Library keyPress

edited October 2013 in Library Questions

I looked around for information on how to create keyPress's with the robot library, and found nothing except for how to move the mouse. SO i started playing around with it and i got something to work:

import java.awt.AWTException;
import java.awt.Robot;

Robot robot;

void setup() {
  size(400, 400);
  try { 
    robot = new Robot();
  } 
  catch (AWTException e) {
    e.printStackTrace();
  }
  robot.keyPress(int);
 }

the int that goes after the keyPress determines what key is pressed, and i tried a bunch. so here you go: if i type "???" then that means that it is not an invalid keyPress, I just dont know what it does. so here we go..

1,2 = invalid

3 = ???

4-7 = invalid

8 = backspace

9 = tab

10 = return

11-15 = invalid

16 = shift

17 = ctrl

18-20 = ???

21-26 = invalid

27-29 = ???

30,31 = invalid

32 = space

33 = pgUP

34 = pgDN

35,36 = ???

37 = left arrow

38 = up arrow

39 = right arrow

40 = down arrow

41-43 = invalid

44 = ,

45 = -

46 = .

47 = /

48 - 57 = 0 - 9

58 = invalid

59 = ;

60 = invalid

61 = =

62 - 64 = invalid

65 - 91 = a - z

92 = \

93 = ]

94,95 = invalid

96 - 105 = 0 - 9

106 = *

107 = +

108 = ???

109 = -

110 = .

111 = /

112 - 116 = ???

i didn't go on any further because i got everything i was after, but i imagine it continues because there are still some characters missing.

my question is, how do i send these keypresses to a specific outside program? thanks!

Tagged:

Answers

  • edited October 2013

    You better learn about what is an ASCII code:
    https://en.wikipedia.org/wiki/Ascii

    You should only concern about which key sub-groups you need to check out and discard the rest!

  • Answer ✓

    AFAIK, you send the key presses to the window that has the system focus... You can click on it to give it the focus.

    Otherwise, specialized automation tools, like AutoHotkey, AutoIt, Sikuli, etc. are better suited for complex operations like sending keys to an arbitrary window.

Sign In or Register to comment.