0
我想写一个程序,根据时间,将鼠标光标移到某个坐标上,而不管用户。我使用Robot编写了一个简单的代码,但遇到了一个问题......我有两个显示器,根据当前显示器的不同,光标移动不正确,请告诉我如何解决问题。JAVA机器人mouseMove 2显示器
下面的代码是什么,我试图创建...
GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] graphicsDevices = graphicsEnvironment.getScreenDevices();
for(int i=0; i < graphicsDevices.length; i++)
{
System.out.println(graphicsDevices[i]);
}
try {
//Robot robot = new Robot(MouseInfo.getPointerInfo().getDevice());
Robot robot = new Robot();
while(true)
{
robot.mouseMove(-1640, -3);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
Thread.sleep(10000);
}
} catch (Exception e) {
e.printStackTrace();
}