I have successfully installed a WH_GETMESSAGE
hook with SetWindowsHookEx
and I can see the WM_POINTERDOWN
, WM_POINTERUP
etc. messages that the application receives. (It is a 32 bit desktop application running on Windows 8.1.)
Now, I not only want to see those messages, but I want to remove some of them.
The documententation for GetMsgProc says:
The GetMsgProc hook procedure can examine or modify the message. After the hook procedure returns control to the system, the GetMessage or PeekMessage function returns the message, along with any modifications, to the application that originally called it.
With WM_KEYUP
messages this seem to work fine. I can set the message to WM_NULL
in the hook, and the key event will disappear.
With WM_POINTER...
messages however, this does not seem to work. The application still receives the messages (validated in the debugger).
Maybe there is some other way to filter/remove such messages?
Edit: It has to work with unmodified third-party applications (hence the usage of a hook).
Update: I managed to prevent click events from touch by aggressively calling PeekMessage
within the hook (probably not a good idea in the long term). However, I still can't prevent scrolling by touch.
WH_GETMESSAGE
is intended for monitoring and modification but not removal. It seems thatWH_KEYBOARD_LL
andWH_MOUSE_LL
do allow removal with both showing this in the documentation: it may return a nonzero value to prevent the system from passing the message to the rest of the hook chain or the target window – AssaiWH_MOUSE_LL
hook receivesWM_POINTER...
messages. But even if doesn't, I might be able to filter the resulting mouse messages. – ComprehendWM_POINTER...
messages don't reach theWM_MOUSE_LL
hook. Also, filtering mouse events is not enough to prevent scrolling by touch. – Comprehend