davidmurphy
asked on
Intercepting WM_KEYDOWN messages
How do I intercept all WM_KEYDOWN messages regardless of which window they routed to ?
Basically I am trying to write an app which will run in the background and monitor all keystrokes and pop up a dialog when it receives a particular keystroke combination.
Basically I am trying to write an app which will run in the background and monitor all keystrokes and pop up a dialog when it receives a particular keystroke combination.
ASKER
Thank you for your answer but I dont think that it is quite what I am looking for.
Isn't there a way of hooking into the windows message queue in the same way (I imagine) that 'Spy' works ?
Thanks
Isn't there a way of hooking into the windows message queue in the same way (I imagine) that 'Spy' works ?
Thanks
I imagine Spy is modifying the window proc...
(in fac you can "empile" the window procs, very usefull !!)
(in fac you can "empile" the window procs, very usefull !!)
You want to look at HOOKs.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
CMyWnd::OnWhatYouWant()
{
//----- do it in every window you want to trace...
OldWndProc = SetWindowLong(m_hWnd, GWL_WNDPROC, NewWndProc)
}
UINT NewWndProc (HWND, MESSAGE, LPARAM, WPARAM)
{
//---- HWND identifies the window !!!
//---- refer to online doc for exact syntax
switch (MESSAGE) {
case WM_KEYDOWN:
ExecMyCode();
break;
}
//---- It is often interesting...
return CallWindowProc(OldWndProc,
}
Good luck