示例#1
0
        public int hookProc(int code, int wParam, ref Utilities.keyboardHookStruct lparam)
        {
            int outcome;

            if (code >= 0)
            {
                Keys vkCode = (Keys)lparam.vkCode;
                if (this.HookedKeys.Contains(vkCode))
                {
                    KeyEventArgs keyEventArgs = new KeyEventArgs(vkCode);
                    if ((wParam == 256 || wParam == 260) && this.KeyDown != null)
                    {
                        this.KeyDown(this, keyEventArgs);
                    }
                    else
                    {
                        if ((wParam == 257 || wParam == 261) && this.Keyup != null)
                        {
                            this.Keyup(this, keyEventArgs);
                        }
                    }
                    if (keyEventArgs.Handled)
                    {
                        outcome = 1;
                        return(outcome);
                    }
                }
            }
            outcome = Utilities.CallNextHookEx(this.hhook, code, wParam, ref lparam);
            return(outcome);
        }
示例#2
0
 private static extern int CallNextHookEx(IntPtr idHook, int nCode, int wParam, ref Utilities.keyboardHookStruct lParam);