private static bool SetHook ()
        {
            if (hookPtr == IntPtr.Zero)
            {
                if (WorkInBackground) hookPtr = Win32API.SetWindowsHookEx(HookType.WH_KEYBOARD_LL, HandleLowLevelHookProc, IntPtr.Zero, 0);
                else hookPtr = Win32API.SetWindowsHookEx(HookType.WH_KEYBOARD, HandleHookProc, IntPtr.Zero, (int)Win32API.GetCurrentThreadId());
            }

            if (hookPtr == IntPtr.Zero) return false;

            return true;
        }
Esempio n. 2
0
        private static bool SetHook()
        {
            if (hookPtr == IntPtr.Zero)
            {
                if (WorkInBackground)
                {
                    hookPtr = Win32API.SetWindowsHookEx(HookType.WH_MOUSE_LL, HandleLowLevelHookProc, IntPtr.Zero, 0);
                }
                else
                {
                    hookPtr = Win32API.SetWindowsHookEx(HookType.WH_MOUSE, HandleHookProc, IntPtr.Zero, (int)Win32API.GetCurrentThreadId());
                }
            }

            if (hookPtr == IntPtr.Zero)
            {
                return(false);
            }

            return(true);
        }