import java.awt.AWTException;
import java.awt.MouseInfo;
import java.awt.Point;
import java.awt.Robot;
import java.awt.event.InputEvent;
public class MyRobot {
public static void main(String[] args) throws AWTException {
Robot robot = new Robot();
robot.mouseMove(0,0);
robot.mouseMove((int)(100/1.25), (int)(100/1.25));
Point point = MouseInfo.getPointerInfo().getLocation();
System.out.println(point);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
// robot.keyPress(KeyEvent.VK_Q);
// robot.keyRelease(KeyEvent.VK_Q);
}
}
参考Link: https://blog.csdn.net/a2387s/article/details/105847781 代码中的1.25是机器屏幕缩放比例,如下: