Robot is part of java.awt package . Robot class is basically used to generate native system input events for the purposes of self- running demos, test automation and other applications where control over mouse and keyboard is used. Robot class generates events that can be used to control mouse, keyboard and can be used to take screenshots of the screen. In this article, we will implement Java Robot to move or drag the mouse to specified location. Methods used :
mouseMove(int x, int y) : move the mouse to a specified location of screen
keyPress(int k) : presses a given key with a specified keycode
keyRelease(int k) : releases a given key with a specified keycode
mousePress(int b) : presses one or more mouse buttons.
mouseRelease(int b) : Releases one or more mouse buttons.
Program 1 : Java program to move a mouse from the initial location to a specified location
Please Login to comment...