-
March 7th, 2013, 11:56 PM
#1
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
-
March 8th, 2013, 03:36 AM
#2
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
-
March 8th, 2013, 09:00 AM
#3
Re: Tired of googling. How to set a global hook to catch WM_MENUSELECT.
That's not what I asked about. >:
-
March 8th, 2013, 09:21 AM
#4
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.
-
March 8th, 2013, 10:20 PM
#5
Re: Tired of googling. How to set a global hook to catch WM_MENUSELECT.
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.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|