Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows scaling also scales mouse-rs locations #12

Open
popcar2 opened this issue May 22, 2022 · 1 comment
Open

Windows scaling also scales mouse-rs locations #12

popcar2 opened this issue May 22, 2022 · 1 comment

Comments

@popcar2
Copy link

popcar2 commented May 22, 2022

I was going mad at how the pointer location was inaccurate before I figured this out: windows scaling options also scales the mouse location when using move_to().
image
Despite my monitor being 1920x1080, move_to() is also scaled by 125%, meaning I reach the bottom right corner of the screen at move_to(1536, 864)

I realize this project hasn't been updated in a year but this is probably unintentional and I hope someone can get around to fixing it.

Worth noting it's not a huge deal if you know the current scale, but the problem is if I'm giving the program to someone else.

let mouse = Mouse::new();
let loc_x = (f64::from(INTENDED_X) / 1.25).floor() as i32; // Assuming you're at 125% scale. 
let loc_y = (f64::from(INTENDED_Y) / 1.25).floor() as i32; // Not 100% accurate because it has to be i32, so I have to floor or get average.
mouse.move_to(loc_x, loc_y);
@AltF02
Copy link
Owner

AltF02 commented May 23, 2022

https://docs.microsoft.com/en-us/windows/win32/api/shellscalingapi/nf-shellscalingapi-getscalefactorformonitor is possibly a solution, adding a loc * scalefactor could do the job

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants