keyboardHook question

F

farseer

Hi,
based on some posts i read, i am using a dll to allow me to do some
keyboard hooking. this is being called from a C# compactfamework app,
which doesn't support delegates. so, i am using a MessageWindow to
send the key presses to the C# app. My question is: there are times,
depending on the key that is pressed, where i want to suppress the
key..so i'd prefer not to call CallNextHookEx in the dll for those
cases. But because i am sending a message to my MessageWindow, the
process is asynchronous. Does anyone have any idea how i can do this?
i was thinking maybe i could go into a lopp after sending the message,
then wait for the C# to set some global value before breaking out of
that loop and decide whether to call CallNextHookEx. would that work?
OR, maybe i can export CallNextHook and have the C# app decide whether
to call it or not?
But then i thought, what sort of timing issues would i run into if
another key is pressed while i'm still passing the last one?

here is my hook proc?

i have dll which allows me to do some keyboard hooking. I am calling
this
MY_API LRESULT CALLBACK keyboardHookProc(int ncode,WPARAM wparam,LPARAM
lparam)
{
if(ncode>=0)
{
SendMessage( _messageWindow, ncode, wparam, lparam);
}

return ( CallNextHookEx( _keyboardHook, ncode, wparam,lparam )
);//pass control to next hook in the hook chain.
}
 
F

farseer

Actually, it seems i was wrong, SendMessage is NOT an ASynchronous
call. this is good.

so what i am doing is marshalling in the KBSTRUCTDLL structure in C#,
using the LPARAM of the Message object, changing it's vkCode to -9999
for keys i want to suppress, then marshalling that back to the ptr. as
far as the marshalling back and forth, that works...as i can see the
dll is reading the -9999 and bypassing the call to CallNextHookEx as i
would like.

the problem is....it appears, some key press is still happening. i
guess i want to cancel the keypress all together in this case. How can
i do that?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top