octalmage / robotjs

Node.js Desktop Automation.
http://robotjs.io
MIT License
12.4k stars 970 forks source link

mouseMove 960, 540 does not move to center of screen 1920x1080 #740

Open Ober3550 opened 1 year ago

Ober3550 commented 1 year ago

Expected Behavior

Mouse moves to center of screen

Current Behavior

Mouse moves to 125% of coordinates

Possible Solution

Within my script multiplying x,y coords by 4/5 gets to the correct location

Steps to Reproduce (for bugs)

robot.mouseMove(960, 540); vs robot.moveMouse((960 4) / 5, (540 4) / 5);

Your Environment

plaili commented 1 year ago

Do you have scaling set to 100%? If not, you have to correct for the scaling factor const display = electron.screen.getPrimaryDisplay() robot.moveMouse(display.size.width * display.scaleFactor, display.size.height * display.scaleFactor)

Muffeter commented 1 year ago

@plaili thank u! I think this should be written in doc. People always ignore scaling.