Deliver MouseEvent to another program?

Back from a long break :wink:

Can anyone give me a quick answer to this question: is there a way for a Java program to deliver mouse and key Events to another program? This is for an extremely crude game bot. What I imagine is there’ll be some kind of System.getActiveWindow() type thing, and then I can post my own events to it. Thanks for any help!

Nope.
JNI for you I’m afraid.

Cas :slight_smile:

the way I do it is use the Robot class to fire off the mouse/key events, and start my app with a Thread.sleep(2000) in there to give me time to alt+tab to the desired application. Or I’d have a window always on top (thank you Java 1.5 :slight_smile: ) and just click a button in my pretty little GUI, and have the Robot move the mouse over to where it needs to go then fire the events. Any window under the mouse will be affected.

Awesome :slight_smile: Thanks guys!