We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello guys
I planned to create a special program only for me and just 4 fun Since a few weeks I had some ideas but today I really started aand then my first problem appeared So no I'm here and really hope you guys could help me
The title says a lot about my little problem I would like to generate an automatically keyPress with my arrows (UP, DOWN, LEFT and RIGHT) So i searched for an answer and then i founded these links about the Robot class:
http://wiki.processing.org/w/Robot_class http://www.elitepvpers.com/forum/coding-tutorials/358215-java-die-robot-class.html
But the first one only describe something with the mouse, and the second only in java
It would be great and I would really appreciate it when you could help me
Thanks for all
David
Answers
hey man of dreams and smileys. i do not totally understand your problem. sure that you need to generate auto keypress for what you want to achieve. what do you want to do? you could just call the code that should be executed when a key is pressed.
removed (no smiliey)
I don't want to call a code that should be executed when a key is pressed. I would like to have a program which generates exactly command which would be called when i would press a key. Then my program replaces necessity to press this key manually.
There's Robot.keyPress() and Robot.keyRelease(). Say you wanted to press space every time that the mouse is pressed:
However, as @mschi has pointed out, it isn't very practical to emulate a key press and then detect it - it would make more sense to call the key press code directly. There may be useful applications of this API for key presses... but keep in mind that this may not be everything that you think it is. AFAIK, you cannot send key events to another application in this way - you can only send key events to the same place that you sent them from (this spoiled my dreams long ago, as well...).
my kind of humour does not translate well to text as it seems :) sorry for making you delete the smileys
@mschi no problem - when i saw it again i also thiught i would be too much ;)
@calsign thanks a lot for this complete answer!
So when it wont be possible to get the key event from one application to the other ... I think the only way i could solve my problem is that i get the other application into processing Does somebody know how i can run a website in processing? :) Or what other kind of applications do i can "import" in processing?
On second thought, it looks like
Robot
might be capable of a little bit more than I thought... it is possible to inject events into another application. I have made the example more Processing-friendly:However, there are two potential issues:
String
into an array ofKeyEvent
s short of a really big switch statement.P.S.: If you're on a Mac, then you might need to change the example...
Thanks a lot - the result is a really amazing little program :)
I changed it a little bit so now it runs on every computer with internet:P
Thanks again for all !
So I see the basic concept for KeyEvent.VK_, but I dont know how to find the codes for special keys, such as fn. Does anyone know where I could find a list of those?