Пример #1
0
        public int HookProc(int code, int wParam, ref WinAPI.KeyboardHookStruct lParam)
        {
            // we only look for keyups and downs
            if (code >= 0 && (wParam == WinAPI.WM_KEYDOWN || wParam == WinAPI.WM_SYSKEYDOWN || wParam == WinAPI.WM_KEYUP || wParam == WinAPI.WM_SYSKEYUP))
            {
                // create out async handler and call it. if we needed to return "handled" chage this to ".Invoke()"
                KeyboardHookEventArgs kea = new KeyboardHookEventArgs((Keys)lParam.vkCode);
                m_hookedAsync.BeginInvoke(wParam, kea, null, null);
            }

            return WinAPI.CallNextHookEx(m_hook, code, wParam, ref lParam);
        }
Пример #2
0
 public static extern IntPtr SetWindowsHookEx(WinAPI.HookType code, KeyboardHookProc callback, IntPtr hInstance, int threadId);