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.
Solution 1:
WH_GETMESSAGE
is not designed to remove or modify messages, only to monitor them. Unfortunately, mark's alternate solution - using WH_KEYBOARD_LL
and WH_MOUSE_LL
- didn't appear to solve the problem either (because multitouch doesn't fall into the category of a mouse message). Sorry, mark!
I'd like to point out WH_CALLWNDPROC
, which receives messages before their intended window. This seems to be the accepted way to modify messages.
Solution 2:
It's possible that the target window doesn't care about WM_POINTER...
messages at all! It could be detecting touch input through the Raw Input API, like this demo here. Try keeping an eye out for WM_INPUT
messages as well.
Note 1: Raw Input messages can be removed, but cannot be modified or created.
Note 2: I'm not entirely sure, but unhandled WM_INPUT
messages might create a memory leak because the thing is practically one massive pointer. Just in case, handle the messages in your hook procedure.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With