Tired of googling. How to set a global hook to catch WM_MENUSELECT.
Hi,
I have a global hook system that uses a dll.
I can install hooks for everything under the sun and my hookproc will see what I expect.
I cannot for the life of me however install a hook and get WM_MENUSELECT coming through to me.
I disparately need to spy on the user and know when file, save is selected, But no joy just yet.
In the below example the first argument for SetWindowHookEx is WH_MOUSE which gives me mouse messages
If I change that to WH_Keyboard, then I get keyboard stuff.
What do I do to see WM_MENUSELECT ? Which is supposed to show the actual menu text which would be perfecto
if only it would work for me.
Hook Set:
HINSTANCE hDLL;
hDLL=LoadLibrary(reinterpret_cast<LPCSTR>("HookDll"));
CBCRMaster::hkbd=SetWindowsHookEx(WH_MOUSE,(HOOKPROC)CBCRMaster::HookProc,hDLL,0);
Thanks in advance,
:Ron
Re: Tired of googling. How to set a global hook to catch WM_MENUSELECT.
Review your code.
Why are you casting to an LPCSTR string here?
Code:
hDLL=LoadLibrary(reinterpret_cast<LPCSTR>("HookDll"));
What's wrong with just doing this?
Code:
hDLL=LoadLibrary("HookDll");
Second, why aren't you checking if hDLL is NULL? If the hDLL is NULL, then you're calling SetWindowsHookEx with a NULL instance, and calling it with a NULL instance changes how it behaves.
Regards,
Paul McKenzie
Re: Tired of googling. How to set a global hook to catch WM_MENUSELECT.
That's not what I asked about. >:
Re: Tired of googling. How to set a global hook to catch WM_MENUSELECT.
You want WH_CALLWNDPROC or WH_CALLWNDPROCRET depending whether you want to trap before or after the program has processed the message.
Re: Tired of googling. How to set a global hook to catch WM_MENUSELECT.
Quote:
Originally Posted by
OReubens
You want WH_CALLWNDPROC or WH_CALLWNDPROCRET depending whether you want to trap before or after the program has processed the message.
Thanks to you, I have it working now.