// Public methods /////////////////////// public static bool Install(Action <Event, Window.Info> onEvent) { if (hookHandles.Count != 0) { return(false); } WinHook.onEvent = onEvent; WinHook.hookDelegate = OnHook; EventLoop.Invoke("win hook", () => { AddHook(EventType.SYSTEM_FOREGROUND); AddHook(EventType.OBJECT_LOCATIONCHANGE); }); return(true); }
// Public methods /////////////////////// public static bool Install( Func <Key, bool> onDown, Func <Key, bool> onUp ) { if (hookHandle != IntPtr.Zero) { return(false); } KeyHook.onDown = onDown; KeyHook.onUp = onUp; KeyHook.hookDelegate = OnHook; EventLoop.Invoke("key hook", () => { hookHandle = SetWindowsHookEx( HookType.KEYBOARD_LOW_LEVEL, KeyHook.hookDelegate, Marshal.GetHINSTANCE(Assembly.GetExecutingAssembly().GetModules()[0]), 0 ); }); return(true); }