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();
}