another question related to key handling...if i am using a dll hook
(LowLevelKeyboardProc) to recieve WM_KEYDOWN messages in my managed
code, is it possible to change the virtual keycode and have it be
effected when CallNextHookEx in the dll is called?
What i have been able to do so far is change data in the
KBDLLHOOKSTRUCT in my managed code, and see that those changes do
persist back to the dll code. But unfortunately, when the changes do
not affect what is outputed to the window/control.
//Here is a snippet of the C# code
protected override void WndProc( ref Message msg )
{
base.WndProc( ref msg );
switch (msg.WParam.ToInt32( ) )
{
case ( int ) API.WM_KEYDOWN:
API.KeybdStruct kbStruct = getKeyStruct( msg.LParam );
kbStruct.vkCode = 65; <--test: change what ever comes
in to an 'A'
kbStruct.scanCode = 0;
System.Runtime.InteropServices.Marshal.StructureToPtr(
kbStruct, msg.LParam, false );
break;
}
}
//Snippet from dll
PHONEHELPER_DLL_API LRESULT CALLBACK keyboardHookProc( int ncode,WPARAM
wparam,LPARAM lparam )
{
if ( ncode == HC_ACTION )
{
if( wparam == WM_KEYDOWN )
{
SendMessage( _messageWindow, ncode, wparam, lparam );
}
}
KBDLLHOOKSTRUCT *kbs = ( KBDLLHOOKSTRUCT* ) lparam;
debug( kbs->vkCode ); <--here any changes made to kbdllhookstruct from
the C# managed code is shown. this works.
return ( CallNextHookEx( _keyboardHook, ncode, wparam,lparam ) );
<--when this is called however, still old char is displayed
}
WHy am i asking? i'd like to implement a means of changing lower case
characters to upper case by double tapping on a key. I can use
registerhotkey, but i have found that it's easy for other apps to
unregister hotkeys and would like to avoid that possibility.