diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f2d41f67..3f23e31e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -67,6 +67,25 @@ jobs: if: runner.os == 'Linux' # This step is only needed on Linux. The other OSs don't need to be set up uses: ./.github/actions/headless_display + - name: Check Mouse Acceleration + run: | + reg query "HKEY_CURRENT_USER\Control Panel\Mouse" /v MouseSpeed + reg query "HKEY_CURRENT_USER\Control Panel\Mouse" /v MouseThreshold1 + reg query "HKEY_CURRENT_USER\Control Panel\Mouse" /v MouseThreshold2 + shell: powershell + - name: Disable Mouse Acceleration + run: | + reg add "HKEY_CURRENT_USER\Control Panel\Mouse" /v MouseSpeed /t REG_SZ /d 0 /f + reg add "HKEY_CURRENT_USER\Control Panel\Mouse" /v MouseThreshold1 /t REG_SZ /d 0 /f + reg add "HKEY_CURRENT_USER\Control Panel\Mouse" /v MouseThreshold2 /t REG_SZ /d 0 /f + shell: powershell + - name: Verify Mouse Acceleration is Disabled + run: | + reg query "HKEY_CURRENT_USER\Control Panel\Mouse" /v MouseSpeed + reg query "HKEY_CURRENT_USER\Control Panel\Mouse" /v MouseThreshold1 + reg query "HKEY_CURRENT_USER\Control Panel\Mouse" /v MouseThreshold2 + shell: powershell + - name: Run the unit tests run: cargo test unit --no-default-features --features ${{ matrix.features }} -- --test-threads=1 --nocapture diff --git a/src/win/win_impl.rs b/src/win/win_impl.rs index a308062f..1f67f6bd 100644 --- a/src/win/win_impl.rs +++ b/src/win/win_impl.rs @@ -164,18 +164,7 @@ impl Mouse for Enigo { let y = (y * 65535 + h / 2 * y.signum()) / h; (MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE, x as i32, y as i32) } else { - // 0-screen width/height - 1 map to 0-65535 - // Add w/2 or h/2 to round off - // See https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-mouse_event#remarks - let (w, h) = self.main_display()?; - let w = w as i64 - 1; - let h = h as i64 - 1; - let x = x as i64; - let y = y as i64; - let x = (x * 65535 + w / 2 * x.signum()) * w; - let y = (y * 65535 + h / 2 * y.signum()) * h; - - (MOUSEEVENTF_MOVE, x as i32, y as i32) + (MOUSEEVENTF_MOVE, x, y) }; let input = mouse_event(flags, 0, x, y, self.dw_extra_info); send_input(&[input])