C# keyhook question
- by user203123
I copied the following code from http://www.codeproject.com/KB/cs/CSLLKeyboardHook.aspx,
public int hookProc(int code, int wParam, ref keyboardHookStruct lParam)
{
if (code >= 0)
{
Keys key = (Keys)lParam.vkCode;
if (HookedKeys.Contains(key))
{
KeyEventArgs kea = new KeyEventArgs(key);
if((wParam == WM_KEYDOWN || wParam == WM_SYSKEYDOWN) && (KeyDown != null))
{KeyDown(this, kea) ;}
else if ((wParam == WM_KEYUP || wParam == WM_SYSKEYUP) && (KeyUp != null))
{KeyUp(this, kea); }
if (kea.Handled)
{return 1;}
}
}
lParam.vkCode ++;
lParam.scanCode ++;
return CallNextHookEx(hhook, code, wParam, ref lParam);
}
It works fine but when I make a little change:
lParam.vkCode ++;
or
lParam.scanCode ++;
right before the return CallNextHookEx(...), the original keys still appears in Notepad.
Ex. If I press "a", I expect the letter in Notepad will be "b" but it still "a".
It seems like "lParam" doesn't change. Couldn't understand why?