How can I implement macOS-style modifier + trackpad zoom (system-wide magnifier) on Windows using Win32/C#?

ketan sharma 0 Reputation points
2025-12-06T06:38:33.41+00:00

I am trying to recreate the macOS accessibility zoom feature on Windows.

On macOS, holding Control and performing a two-finger scroll on the trackpad triggers a system-wide zoom:

  • The entire screen zooms
  • The zoom centers on the mouse cursor
  • Moving the mouse pans the magnified area
  • This works consistently across all applications

I am attempting to implement the same behavior on Windows using:

  • C#
  • Low-level mouse hooks (WH_MOUSE_LL)
  • Windows Magnification API (Magnification.dll)

My approach:

  • Install a WH_MOUSE_LL hook
  • Detect CTRL + mouse wheel (two-finger trackpad scroll)
  • Adjust magnification via MagSetFullscreenTransform
  • Recenter the zoom based on GetCursorPos

The magnifier itself works, and panning follows the mouse correctly WHEN input is received.

However, I am running into a major limitation:

❗ The mouse wheel input is ONLY detected when the cursor is over the console window that launched the process.

❗ When the cursor is over other applications (e.g. Chrome), the hook does not receive wheel events.

❗ As a result, CTRL + two-finger scroll only zooms when hovering over the console window.

❗ Regular mouse wheel events DO propagate globally, but trackpad gestures do not.

Observations:

  • This occurs even when the executable is run outside Visual Studio
  • It happens regardless of administrator privileges
  • Some apps (e.g. Ableton Live) partially work, others (Chrome) do not
  • Keyboard-based zoom (CTRL +/-) still works globally, so magnification itself is not the issue

I suspect this relates to how Windows handles trackpad gestures, WM_GESTURE / WM_POINTER / precision touchpad input, and how those events bypass low-level mouse hooks.

Questions:

  1. Is it possible to implement macOS-style modifier + trackpad zoom system-wide on Windows at all?
  2. If so, should this be done via Raw Input / WM_POINTER / HID instead of WH_MOUSE_LL?
  3. Are trackpad scroll gestures intentionally not exposed to global mouse hooks?
  4. Is this behavior a known architectural limitation of Windows input handling?

I am not trying to zoom within a specific application — this must be system-wide, OS-level magnification.

Any insight into the correct Windows-native approach would be greatly appreciated.

if (wParam == (IntPtr)WM_MOUSEWHEEL && ctrlDown)

{

_currentZoom += wheelDelta / 1200f;

MagSetFullscreenTransform(_currentZoom, xOffset, yOffset);

}

Windows development | Windows API - Win32
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Jack Dang (WICLOUD CORPORATION) 5,610 Reputation points Microsoft External Staff Moderator
    2025-12-08T08:56:00.6466667+00:00

    Hi @ketan sharma ,

    Thanks for reaching out.

    Is it possible to implement macOS-style modifier + trackpad zoom system-wide on Windows at all?

    Not directly using WH_MOUSE_LL. Windows does not expose trackpad two-finger scroll gestures globally through low-level mouse hooks. System-wide detection of such gestures is limited due to how Windows handles precision touchpad input (WM_POINTER / WM_GESTURE). So, a macOS-style zoom is possible, but it requires a different input handling approach.

    This documentation describes how Windows processes modern pointer input (including touchpad gestures), which explains why these events don’t flow through low-level mouse hooks:

    Pointer Input Messages and Notifications – Microsoft Docs


    If so, should this be done via Raw Input / WM_POINTER / HID instead of WH_MOUSE_LL?

    Yes. To reliably detect two-finger scroll gestures from a trackpad, you would need to use Raw Input, HID APIs, or handle WM_POINTERWHEEL messages. These methods allow you to process touchpad gestures outside of a single application window, which WH_MOUSE_LL cannot.

    This documentation explains how Raw Input provides access to device-level input beyond what hooks can receive:

    Raw Input – Microsoft Docs

    This documentation describes WM_POINTERHWHEEL, which is the event precision touchpads use for wheel-like gestures:

    WM_POINTERHWHEEL – Microsoft Docs


    Are trackpad scroll gestures intentionally not exposed to global mouse hooks?

    Yes, this is by design. Windows treats precision touchpad gestures differently from traditional mouse wheel input. They are delivered as pointer or gesture messages to the window under the cursor rather than through global mouse hooks.

    This documentation explains the architecture behind Precision Touchpads and why gestures bypass legacy mouse input paths:

    Windows Precision Touchpad Devices – Microsoft Docs


    Is this behavior a known architectural limitation of Windows input handling?

    Yes. It’s a known limitation. Global hooks only capture traditional mouse events. Trackpad gestures bypass these hooks, which is why your current implementation only works over your console window.

    This documentation outlines how touchpads process gestures at a higher level, preventing them from being intercepted by low-level mouse hooks:

    Touchpad Implementation Guide – Microsoft Docs


    Recommended approach:

    1. Continue using the Windows Magnification API (Magnification.dll) for zooming.
    2. Replace the WH_MOUSE_LL hook with Raw Input / HID handling / WM_POINTER messages to detect two-finger scroll gestures system-wide.
    3. Combine this with your existing cursor-based panning logic for a macOS-like experience.

    Hope this helps! If my answer was helpful - kindly follow the instructions here so others with the same problem can benefit as well.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.