Reputation: 193
I like to do a program which can control other program(window). I would like that my program automatically click button and get others states. But for now i am just asking how to access to this other program/process with java.
Upvotes: 1
Views: 1359
Reputation: 8426
Try java.awt.Robot
How to press keys
import java.awt.Robot;
import java.awt.event.KeyEvent;
Robot robot = new Robot();
static int keyInput[] = { KeyEvent.VK_SPACE };
robot.keyPress(keyInput[i]);
How to manipulate mouse
import java.awt.event.InputEvent;
robot.mouseMove(300, 550);//MOVING MOUSE
r.mousePress(InputEvent.BUTTON1_MASK); // CLICKING MOUSE
InputEvent.BUTTON1_MASK
= left button
InputEvent.BUTTON2_MASK
= middle button
InputEvent.BUTTON3_MASK
= right button
Here's a good tutorial to start
Upvotes: 5