java code to click mouse and press keys?
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
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
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?
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:
Would this work?
I've never used this class, but it looks like that's how it's designed...
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center