Global keyboard/mouse hook in processing?

edited November 2013 in How To...

Is it possible to register when mouse or keyboard is pressed outside the processing frame? So some sort of global function that allows me to track whether mousePressed() or keyPressed() == true no matter where I am on the screen and what program I am in?

Answers

  • I assume you want a Processing sketch to be aware of mouse and key events that occur outside the sketch's window.

    If that is the case then the answer is no since mouse and key events are sent to the active application and if you click outside Processing then something else becomes active and receives these events.

  • Yes that was what I wanted. Not what particular keys you are typing, but whether you type/click or not. I have seen something with NativeHooks in Java, but I guess you cannot use that in processing?

  • Also, I have seen that it is possible to register the x and y mouse value outside the frame. It wouldn't be possible to write your own "MouseListener/keylistener" function that registers the events outside the frame, would it? Or make the program run in the background but still being able to register events...

  • Not familiar with NativeHooks so I googled and came up with this library. Is this what you mean?

    It seems this library might do what you want but I am not familiar with it.

  • Avoid making duplicate threads, please.

Sign In or Register to comment.