F
farseer
hi,
based on a few posts i have read here, i created a dll that allows me
to perform low level keyboardhooking from my C# code. this works great
and i send to a MessageWindow, certain WM_KEYDOWN messages.
What i would now like to do is if i detect certain keys (regardless of
what process they eminated from), set focus to a control on a form, and
cancel the keypress all together. Is this possible?
What i have attempted are two things:
1. don't call CallNextHookEx. when i bypass that call, the same
message is sent repeatedly to my MessageWindow (i.e. the last message
sent from the dll's HookProc). why?
2. i marhall in the KBDLLHOOKSTRUCT structure in the C# code, change
the vkcode and scancode to something like -9999, and marshall that back
to a ptr (i.e. the memory block the C code is referencing). The
marshalling works (i see the -9999 being processed by the dll), but the
keydown is still processed and does something. Why i say this is that
in by C# code, i can set focus to the control i want to when i recieve
the right arrow key press, but as soon as the HookProc call is
completed in the dll, the control looses focus (no longer has that dark
border indicating it has the focus)
anyone has any idea of how to solve this problem?
based on a few posts i have read here, i created a dll that allows me
to perform low level keyboardhooking from my C# code. this works great
and i send to a MessageWindow, certain WM_KEYDOWN messages.
What i would now like to do is if i detect certain keys (regardless of
what process they eminated from), set focus to a control on a form, and
cancel the keypress all together. Is this possible?
What i have attempted are two things:
1. don't call CallNextHookEx. when i bypass that call, the same
message is sent repeatedly to my MessageWindow (i.e. the last message
sent from the dll's HookProc). why?
2. i marhall in the KBDLLHOOKSTRUCT structure in the C# code, change
the vkcode and scancode to something like -9999, and marshall that back
to a ptr (i.e. the memory block the C code is referencing). The
marshalling works (i see the -9999 being processed by the dll), but the
keydown is still processed and does something. Why i say this is that
in by C# code, i can set focus to the control i want to when i recieve
the right arrow key press, but as soon as the HookProc call is
completed in the dll, the control looses focus (no longer has that dark
border indicating it has the focus)
anyone has any idea of how to solve this problem?