hi everybody
I've already successfully implemented a globally low level keyboard and mouse hook and it seems that this is all .net managed code could provide in global hooking. But after I got the message by the hook, where is this keyboard or mouse message going to the parameters and structures of hook event don't contain that information. any idea
thanks in advance

Where are the messages going to?
Alex Yakhnin - MSFT
ktto
Robert A. Swirsky
Chris Holt
mhadamji
All messages go to a window, whether posted or sent.
You don't get a window handle because there's really nothing you can do with it. WH_KEYBOARD_LL is an out-of-process hook, which is processed in its own process, not the process for which the message is intended. If you did have a window handle, you couldn't use SendMessage because you're on a different thread; and if you use PostMessage you can't pass any pointers to anything in your address space because you're in a different address space than the destination application.
You can try to get the current foreground window (the window with focus) with GetForegroundWindow(). That should be the window for which the message is destined. Keep in mind, the message you're getting in your hook proc is received at a different time to when it was "created", so in the time between when the message was created and when it was sent to your hook proc the foreground window may have changed.
What do you want to do with the window handle
zulu5255
Tim Hunter
well, I hooked globally with WH_KEYBOARD_LL so I could receive all the keyboard messages system wide. When the message came and the event fired, I got only three parameters:
int nCode indicate if you should pass the keyboard message directly to the next hook
UIntPtr wParam identifier of the keyboard message. It could be WM_KEYDOWN, WM_KEYUP, WM_SYSKEYDOWN, WM_SYSKEYUP
IntPtr lParam a pointer to KBDLLHOOKSTRUCT structure, but there is no handle in it indicating where is this keyboard message going to
How can I know where this message goes
joeydj
The application with the active window is the likely destination of the message.