Пример #1
0
        private IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
        {
            try
            {
                return(InnerHookCallback(nCode, wParam, lParam));
            }
            catch (Exception)
            {
                //Ignore this
            }

            return(KeyInterceptor.CallNextHookEx(_HookID, nCode, wParam, lParam));
        }
Пример #2
0
        private IntPtr InnerHookCallback(int nCode, IntPtr wParam, IntPtr lParam)
        {
            if (nCode >= 0)
            {
                if (wParam == (IntPtr)KeyInterceptor.KeyDown)
                {
                    KeyDown(this, new RawKeyEventArgs(Marshal.ReadInt32(lParam), false));
                }
                else if (wParam == (IntPtr)KeyInterceptor.KeyUp)
                {
                    KeyUp(this, new RawKeyEventArgs(Marshal.ReadInt32(lParam), false));
                }
            }

            return(KeyInterceptor.CallNextHookEx(_HookID, nCode, wParam, lParam));
        }