Loading...
Logo
Processing Forum
I want to know if Processing can press a key on windows, the user is gonna use a kinect-like sensor to interact with some basic functions, we need to send key presses though. After some research, I found this "Robot" class, which seems to do exactly what I want, but maybe it's Arduino only?

I import the class with "import java.awt.Robot;", but on the line "r.keyPress(CAPS_LOCK);" I get this error:

Exception in thread "Animation Thread" java.lang.NullPointerException
at KeyPress.draw(KeyPress.java:40)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PApplet.run(Unknown Source)
at java.lang.Thread.run(Thread.java:662)


Win7 64 bits, Java 32 bits, default Processing install (only unzipped and ran), only extra library is SimpleOpenNI.

Replies(3)

Maybe this helps?  http://processing.org/reference/keyPressed_.html

An example:
Copy code
  1. void setup() {
  2.   size(100, 100);
  3. }

  4. void draw() {
  5. }

  6. void keyPressed() {
  7.   if (key == 'a') println("a");
  8. }
" on the line "r.keyPress(CAPS_LOCK);" I get this error:"
See Why do I get a NullPointerException?
If you give a line in isolation, it is hard to tell what error you did.
Beside, how CAPS_LOCK is defined?
My bad guys, shouldn't try these stuff so late at night. I had forgotten to instantiate my "r"/Robot var on the setup method.