Create a WPF window that captures and passes through mouse events

I am working on a screen capture utility that captures active windows. I use transparent overlays to capture the full screen, and then overlay the active windows based on mouse movement events that passed through the main desktop / windows.

Both overlay windows currently use a style WS_EX_TRANSPARENTto allow mouse events to go through the base windows so that I can determine where the mouse cursor is. I grab the window handle and rectangle size to outline the window, and then use Global Mouse and Keyboard Hooks to accept or reject the capture.

This is a pretty ugly and common code (that’s why I don’t post it here right now), but it works very well and I can select windows in mousemove and capture clicks with a global mouse and key handlers.

Everything works except this problem :

Global Windows Hooks do not start the admin window, so when I want to capture Powershell, Command or Visual Studio (in administrator mode), hook events are not forwarded.

There seems to be no way around these security issues with Windows interceptors (or GetAsyncKeystate(), for that matter).

I tried several different approaches to solving this problem:

  • Hooks /

    , - , ( ) (.. )

  • Win32 GetAsyncKeystate(), , , .

, : Hooks GetAsyncKeyState, , , , .

, :

, mouseclicks ?

+4

Source: https://habr.com/ru/post/1661812/


All Articles