What does WPF use to capture mouse and keyboard input?

前端 未结 2 1430
灰色年华
灰色年华 2020-12-28 09:09

I globally (system-wide) filter certain mouse clicks using SetWindowsHookEx and WH_MOUSE_LL. The problem is it doesn\'t work for WPF applications (

2条回答
  •  星月不相逢
    2020-12-28 09:42

    • WPF Window creates HwndSource (Window.CreateSourceWindow).
    • HwndSource creates HwndWrapper (HwndSource.Initialize).
    • HwndWrapper creates Win32 window with window procedure that delegate Windows messages to hooks, specified by HwndSource.
    • One hook is the HwndSource.InputFilterMessage that delegate Windows messages to four input providers: stylus, mouse, keyboard, appcommand.
    • Provider parses appropriate Windows message and invokes InputManager to raise input events on elements.

    HwndMouseInputProvider process messages such as WM_MOUSEMOVE, WM_LBUTTONDOWN, etc. So I think there is no DirectInput used to handle mouse and keyboard input.

提交回复
热议问题