I'm looking for a possibility to to this basically: User clicks, holds, moves to left and releases. EDIT: I mean not by an user, but automated. Any methods which offer this?
Asked
Active
Viewed 134 times
-5
-
Java SE for desktop ? – Jonathan Solorzano Aug 05 '15 at 19:44
-
could you describe what exactly you don't know what to do, what have you tried? – Jonathan Solorzano Aug 05 '15 at 19:45
-
I know how to make a click with the robot class, but it has to drag it accross the screen before releasing. – Tim V Aug 05 '15 at 19:51
1 Answers
1
To automate mouse clicks, holds and moves you can look into the Robot Class
This is the basics of a mouse click: where x
and y
is the coordinate of the point on the screen in pixels where you want to click.
public static void click(int x, int y) throws AWTException{
Robot bot = new Robot();
bot.mouseMove(x, y);
bot.mousePress(InputEvent.BUTTON1_MASK);
bot.mouseRelease(InputEvent.BUTTON1_MASK);
}
Other mouse functionality can be acheived through Selenium
Really depends on what you specfically want to acheive
See:
How to perform mouseover function in Selenium WebDriver using Java?
How to simulate a real mouse click using java?
If you record the coordinates accurately enough, and loop the amount of times you want to do the processes; you can pretty much automate most mouse clicks/drags.

Community
- 1
- 1

Huang Chen
- 1,177
- 9
- 24