Hello there,
Is it possble to write a java program that is able to press the mouse keys and/or press the keyboard keys by itself? (say "keypress.A" , "mouseclick.LEFT") If it can, which class should I use?
Thank you very much
Printable View
Hello there,
Is it possble to write a java program that is able to press the mouse keys and/or press the keyboard keys by itself? (say "keypress.A" , "mouseclick.LEFT") If it can, which class should I use?
Thank you very much
Hello,
Java provide a convenient API for emulating keyboard and mouse inputs.
I suggest you to check the Robot's class : http://java.sun.com/j2se/1.4.2/docs/...awt/Robot.html
Hi
Thank you very your reply. I've tried using the robot class and the KeyEvent, but the KeyEvent seems only can press the key once, (say robot.keypress(KeyEvent.VK_LEFT) ) Is it possible to press a specific key for a period of time then release it? Moreover, I want to use this program after activating a certain window, say notepad1.txt, which class should I use to archieve that?
Thank you
Hi again,
It sounds me that all you have to do is to press/release a key repeatedly for a period of time. I gess you could achieve this easily by using Swing timer:
http://java.sun.com/docs/books/tutor...isc/timer.html
Best regards,
Would this work?
I've never used this class, but it looks like that's how it's designed...Code:robot.keyPress(...);
robot.delay(3000);
robot.keyRelease(...);