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

Inconsistent pixel units #91

Closed
ArturKovacs opened this issue Mar 7, 2020 · 4 comments · Fixed by #149
Closed

Inconsistent pixel units #91

ArturKovacs opened this issue Mar 7, 2020 · 4 comments · Fixed by #149

Comments

@ArturKovacs
Copy link

Hello! From windows 10 the parameters of mouse_move_to seem to be physical-pixel-units but the parameters of mouse_move_relative seem to be logical-pixel-units. The two functions should preferably operate on the same units and the kind of units should be stated in the documentation.

Minimal code example:

let mut enigo = Enigo::new();
enigo.mouse_move_to(100, 100);
// Comment out the following function call and un-comment the line after
// and the cursor will end up at a different location if the display scaling is not a 100%
enigo.mouse_move_to(150, 150);
//enigo.mouse_move_relative(50, 50);
  • OS: Windows 10
  • Rust: rustc 1.41.1 (f3e1a954d 2020-02-24)
  • Library Version: enigo 0.0.14
@FlareFlo
Copy link

I stumbled on the same problem and found it was related to the windows mouse speed setting

@pentamassiv
Copy link
Collaborator

I looked at the documentation and our code and the reason why there is a difference between mouse_move_to and mouse_move_relative is because of the flag MOUSEEVENTF_VIRTUALDESK. The docs say:

Maps coordinates to the entire desktop. Must be used with MOUSEEVENTF_ABSOLUTE.

So I seems to be impossible to be used in mouse_move_relative. In order to get a consistent behavior between both functions, I believe we have to call mouse_location and then calculate the new coordinates.

@FlareFlo
Copy link

maybe make a wrapper function that does exactly that? the regular relative_move function seems pretty useless if it has such issue

pentamassiv added a commit to pentamassiv/enigo that referenced this issue Feb 15, 2023
pentamassiv added a commit to pentamassiv/enigo that referenced this issue Feb 15, 2023
pentamassiv added a commit to pentamassiv/enigo that referenced this issue Feb 15, 2023
pentamassiv added a commit to pentamassiv/enigo that referenced this issue Feb 15, 2023
@FlareFlo
Copy link

awesome!

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

Successfully merging a pull request may close this issue.

3 participants