0

I installed a low-level mousehook (WH_MOUSE_LL) to get the correct screen cursor position on a mixed HiDpi system (two monitors) (the application itself is not HiDpi aware). How can I change the mouse position in code so that the hook is called as well. Ultimately I just want to pick a color on the screen of a multi-monitor solution from a non-HiDpi-aware application, with the resolutions and scalings of the monitors being different. I would also like to be able to move the cursor with pixel precision using the cursor keys.

I've tried SetCursorPos() and SetPhysicalCursorPos(). In both cases, the cursor position is changed, but the hook is not called. I have not found any way to map then HigDpi-coordinates received in the low-level-mousehook to my non HigDpi-aware application.

AWirthK2
  • 46
  • 2
  • 2
    Call [`SendInput`](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-sendinput) to synthesize mouse input. Input events get queued at a point early enough in the input processing pipeline so that they will to through low-level hook processing. This may or may not work for you, as low-level hooks get notified that the input was injected, and hooks can choose to ignore injected input. – IInspectable Aug 17 '23 at 17:32
  • @IInspectable that should be an answer instead of a comment – Remy Lebeau Aug 17 '23 at 20:14
  • SendInput works fine for me. Thanks. – AWirthK2 Aug 18 '23 at 12:42

1 Answers1

0

According to @IInspectable's suggestion:

You could try to call SendInput to synthesize mouse input. Input events get queued at a point early enough in the input processing pipeline so that they will to through low-level hook processing. This may or may not work for you, as low-level hooks get notified that the input was injected, and hooks can choose to ignore injected input.

Jeaninez - MSFT
  • 3,210
  • 1
  • 5
  • 20