Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Windows hooks and message delivery

1 view
Skip to first unread message

Ranju. V

unread,
Jul 4, 2006, 7:22:39 AM7/4/06
to
Hi,

I am working on an application that needs to detect keyboard/mouse
events raised in the system *after* they have been delivered to the
target program. I tried using windows hooks (SetWindowsHookEx) but
they seem to get delivered before being sent to the target program.

Is there any way this can be done? Please help.

Thanks.

--
Ranju. V
http://blogorama.nerdworks.in/
--

Ranju. V

unread,
Jul 5, 2006, 8:56:29 AM7/5/06
to
Ranju. V wrote:
> I am working on an application that needs to detect keyboard/mouse
> events raised in the system *after* they have been delivered to the
> target program. I tried using windows hooks (SetWindowsHookEx) but
> they seem to get delivered before being sent to the target program.

I managed to figure this one out myself. It turns out that if you call
"CallNextHookEx" first then the message gets processed just fine. So
where I was doing this from the hook routine before:

PostMessage( hwndTarget, WM_HOOKED, 0, 0 );
return CallNextHookEx( NULL, nCode, wParam, lParam );

I changed it to look like this:

LRESULT lResult = CallNextHookEx( NULL, nCode, wParam, lParam );
PostMessage( hwndTarget, WM_HOOKED, 0, 0 );
return lResult;

And that's it!

0 new messages