Robot.mouseMove does not move the mouse at all

16 views Asked by At

I'm running a small java app which needs to move the mouse to various positions on the screen, but my code to do so doesn't move the mouse at all.

I'm using Robot.mouseMove on version 20.0.1 and honestly I can't figure out why this would fail beside a problem with Robot.mouseMove itself.
MRE:

import java.awt.*;

class Test {
    public static void main(String[] args) throws AWTException {
        Robot robot = new Robot();
        robot.mouseMove(500, 500);
    }
}

I've also tried just repeatedly moving the mouse like below just in case the method just silently fails sometimes:

Point pt = new Point(x, y);
int n = 0;
while ((!pt.equals(MouseInfo.getPointerInfo().getLocation())) && (n++ < 10)) {
    robot.mouseMove(x, y);
}

but this doesn't work either.

0

There are 0 answers