public SingleMouseClientAndDispatcher(CommunicationLogic logic) { this.logic = logic; mouseProc = mouseHook_MessageIntercepted; hookId = SetHook(mouseProc); id = 0; }
public static void Start() { var hMod = Marshal.GetHINSTANCE(Assembly.GetExecutingAssembly().GetModules()[0]); _hookProc = HookProc; _hHook = NativeMethods.SetWindowsHookEx(NativeMethods.WH_MOUSE_LL, _hookProc, hMod, 0); ChangeCursor(); }
private static IntPtr SetHook(NativeMethods.LowLevelMouseProc proc) { using (Process curProcess = Process.GetCurrentProcess()) using (ProcessModule curModule = curProcess.MainModule) { return(NativeMethods.SetWindowsHookEx(WinAPI.WH_MOUSE_LL, proc, NativeMethods.GetModuleHandle(curModule.ModuleName), 0)); } }
/// <summary> /// Activates tool in system. /// </summary> /// <returns>false value if it was already activated before, otherwise true.</returns> public bool plug() { if (mhook != IntPtr.Zero) { return(false); } llMouseProc = new NativeMethods.LowLevelMouseProc(lowLevelMouseProc); // to protect from GC mhook = NativeMethods.SetWindowsHookEx ( WindowsHookId.WH_MOUSE_LL, llMouseProc, Marshal.GetHINSTANCE(Assembly.GetExecutingAssembly().ManifestModule), 0 ); if (mhook == IntPtr.Zero) { throw new WinFuncFailException(); } LSender.Send(this, $"mhook + {mhook}", Message.Level.Debug); return(true); }
public GlobalColorPickOperation() { // This is needed in order to stop the Garbage Collector from removing the hook this.mouseHook = this.MouseHookCallback; }
public MouseHookBase() { _proc = HookCallback; Hook(); }
public InterceptMouse() { _proc = HookCallback; }