Reputation: 1
I know with the robot class I can move my mouse to an (x,y) coordinate but is there a way to return this (x,y) coordinate that my mouse is currently hovering over? Or possibly a way to see the (x,y) coordinate that I have last clicked.
I'm using the returns to map out a specific order of coordinates that need to be clicked and I don't want to guess which pixel it is on a 4k screen.
Upvotes: 0
Views: 102
Reputation: 5629
PointerInfo a = MouseInfo.getPointerInfo();
Point b = a.getLocation();
int x = (int) b.getX();
int y = (int) b.getY();
Robot r = new Robot();
r.mouseMove(x + 100 , y + 100 );
Upvotes: 1