On my Windows 10 machine, using Java 17, I have two monitors. A 1440p primary monitor (scaled to 125%) and a 1080p secondary monitor. I created a class that records time and mouse location (x,y coordinates) and another class to play back the recorded actions.
On playing back the actions, I noticed that as it got closer to the bottom of the screen, the actions movements from robot.mouseMove(x,y)
were less and less accurate compared to the location they should have been moving to. After troubleshooting, I realized this was due to my primary monitor scaling, and that the issue (for my main monitor) is resolved through robot.mouseMove((int) (x/1.25), (int) (y/1.25));
But then the mouseMove()
method breaks for the secondary monitor. I could easily hardcode the movement function to check if(x > 2560) { <Do_Things_Without_Scaling> }
, or set my primary monitor to 100% scaling and have the coordinates match up.
With the hardcoded solutions acknowledged, is there a known way with the robot class to handle two monitors of different scalings? It seems to be doing fine with coordinates and them being different resolutions, but the scaling differences keeps throwing it off and making any recorded action not true to the coordinate logs.