C # - determine if a user moves a window

I am going to check if the user is moving in any window (my application does not have an interface) and reacts accordingly. What do you think is the best way to do this? Can I tell if the user clicks on the header? Can I tell if a window is moving? Then I need to capture the hWnd window after I know that it is moving.

+4
source share
2 answers

To receive notifications about all windows, and not just in Windows Forms, you will need to use the set of hooks specified by the SetWindowsHookEx () API function. You will need a WH_CALLWNDPROC hook so you can see the WM_MOVE message that Windows sends to the window.

Unfortunately, this is a global hook. Code that implements a hook callback must be packaged in a DLL so that it can be embedded in all target processes. This breaks the hole in your plans to use C # for this, you cannot enter the CLR. DLL must be written in unmanaged code.

This one offers an approach, including the unmanaged injection DLL you need.

+5
source

here is the spy method in windows. You can check all open and pending move messages.

EDIT

. NET spyware code .

+4
source

All Articles