コード例 #1
0
        // Check to see if the depressed key was the one in the watch list combined with the CONTROL key. If it is, call the key press even.
        public int hookProc(int code, int wParam, ref kbHookStruct lParam)
        {
            if (code >= 0)

            {
                Keys key = (Keys)lParam.vkCode;
                if (HookedKeys.Contains(key) && Control.ModifierKeys == Keys.Control)
                {
                    KeyEventArgs kea = new KeyEventArgs(key);
                    if ((wParam == WM_KEYDOWN || wParam == WM_SYSYKEYDOWN) && (KeyDown != null))
                    {
                        KeyDown(this, kea);
                    }
                    else if ((wParam == WM_KEYUP || wParam == WM_SYSKEYUP) && (KeyUp != null))
                    {
                        KeyUp(this, kea);
                    }
                    if (kea.Handled)
                    {
                        return(1);
                    }
                }
            }
            return(CallNextHookEx(hhook, code, wParam, ref lParam));
        }
コード例 #2
0
        // Check to see if the depressed key was the one in the watch list combined with the CONTROL key. If it is, call the key press even.
        public int hookProc(int code,int wParam, ref kbHookStruct lParam)
        {
            if(code >= 0)

            {
                Keys key = (Keys)lParam.vkCode;
                if(HookedKeys.Contains(key) && Control.ModifierKeys == Keys.Control){
                    KeyEventArgs kea = new KeyEventArgs(key);
                    if((wParam == WM_KEYDOWN|| wParam == WM_SYSYKEYDOWN) && (KeyDown != null))
                    {KeyDown(this, kea);}
                    else if((wParam == WM_KEYUP || wParam == WM_SYSKEYUP) && (KeyUp != null))
                    {
                        KeyUp(this, kea);
                    }
                    if (kea.Handled)
                        return 1;

               }
            }
            return CallNextHookEx(hhook, code, wParam, ref lParam);
        }
コード例 #3
0
 static extern int CallNextHookEx(IntPtr idHook, int nCode, int wParam, ref kbHookStruct lParam);
コード例 #4
0
 static extern int CallNextHookEx(IntPtr idHook, int nCode, int wParam, ref kbHookStruct lParam);