Exemple #1
0
        private static IntPtr MouseHookProc(int nCode, WindowsMessagesFlags wParam, LowLevelMouseHookStruct lParam)
        {
            if (nCode >= 0 && registeredMouseHooks != null)
            {
                foreach (var h in registeredMouseHooks)
                {
                    Union32 union = new Union32(lParam.mouseData);

                    bool isXButton = h.KeyOrButton.MouseButton == MouseAction.XButton1 || h.KeyOrButton.MouseButton == MouseAction.XButton2;
                    bool isMWheel  = h.KeyOrButton.MouseButton == MouseAction.MWheelUp || h.KeyOrButton.MouseButton == MouseAction.MWheelDown;

                    if (isXButton && wParam == WindowsMessagesFlags.WM_XBUTTONUP)
                    {
                        if (h.TestModifiers() && (union.High == 0x0001 && h.KeyOrButton.MouseButton == MouseAction.XButton1 ||
                                                  union.High == 0x0002 && h.KeyOrButton.MouseButton == MouseAction.XButton2))
                        {
                            HotkeyActionCallback(h);
                        }
                    }
                    else if (isMWheel && wParam == WindowsMessagesFlags.WM_MOUSEWHEEL)
                    {
                        short delta = unchecked ((short)union.High);
                        if (h.TestModifiers() && (delta > 0 && h.KeyOrButton.MouseButton == MouseAction.MWheelUp ||
                                                  delta < 0 && h.KeyOrButton.MouseButton == MouseAction.MWheelDown))
                        {
                            HotkeyActionCallback(h);
                        }
                    }
                }
            }

            return(User32.CallNextHookEx(hMouseHook, nCode, wParam, lParam));
        }
Exemple #2
0
        private IntPtr MouseHookProc(int nCode, WindowsMessagesFlags wParam, LowLevelMouseHookStruct lParam)
        {
            if (nCode >= 0)
            {
                foreach (IMouseHookHotkey h in this.registeredHotkeys)
                {
                    var union = new Union32(lParam.mouseData);

                    bool isXButton = h.MouseButton == MouseAction.XButton1 || h.MouseButton == MouseAction.XButton2;
                    bool isMWheel  = h.MouseButton == MouseAction.MWheelUp || h.MouseButton == MouseAction.MWheelDown;

                    if (isXButton && wParam == WindowsMessagesFlags.WM_XBUTTONUP)
                    {
                        if (h.AreModifiersPressed() && (union.High == 0x0001 && h.MouseButton == MouseAction.XButton1 ||
                                                        union.High == 0x0002 && h.MouseButton == MouseAction.XButton2))
                        {
                            this.Visit(h);
                        }
                    }
                    else if (isMWheel && wParam == WindowsMessagesFlags.WM_MOUSEWHEEL)
                    {
                        short delta = unchecked ((short)union.High);
                        if (h.AreModifiersPressed() && (delta > 0 && h.MouseButton == MouseAction.MWheelUp ||
                                                        delta < 0 && h.MouseButton == MouseAction.MWheelDown))
                        {
                            this.Visit(h);
                        }
                    }
                }
            }

            return(User32.CallNextHookEx(this.hMouseHook, nCode, wParam, lParam));
        }
        private IntPtr MouseHookProc(int nCode, WindowsMessagesFlags wParam, LowLevelMouseHookStruct lParam)
        {
            if (nCode >= 0)
            {
                if (this.TxtSingleKey.IsFocused)
                {
                    if (wParam == WindowsMessagesFlags.WM_XBUTTONUP)
                    {
                        Union32 union = new Union32(lParam.mouseData);

                        if (union.High == 0x0001)
                        {
                            this.TxtSingleKey.Text = MouseAction.XButton1.ToString();
                            if (this.LstHotKeys.SelectedItem is Hotkey hotkey)
                            {
                                hotkey.KeyOrButton = MouseAction.XButton1;
                            }
                        }
                        else if (union.High == 0x0002)
                        {
                            this.TxtSingleKey.Text = MouseAction.XButton2.ToString();
                            if (this.LstHotKeys.SelectedItem is Hotkey hotkey)
                            {
                                hotkey.KeyOrButton = MouseAction.XButton2;
                            }
                        }
                    }
                    else if (wParam == WindowsMessagesFlags.WM_MOUSEWHEEL)
                    {
                        Union32 union = new Union32(lParam.mouseData);

                        short delta = unchecked ((short)union.High);
                        if (delta > 0)
                        {
                            // MWheelUp
                            this.TxtSingleKey.Text = MouseAction.MWheelUp.ToString();
                            if (this.LstHotKeys.SelectedItem is Hotkey hotkey)
                            {
                                hotkey.KeyOrButton = MouseAction.MWheelUp;
                            }
                        }
                        else if (delta < 0)
                        {
                            // MWheelDown
                            this.TxtSingleKey.Text = MouseAction.MWheelDown.ToString();
                            if (this.LstHotKeys.SelectedItem is Hotkey hotkey)
                            {
                                hotkey.KeyOrButton = MouseAction.MWheelDown;
                            }
                        }
                    }
                }
            }

            return(User32.CallNextHookEx(this.hHook, nCode, wParam, lParam));
        }
Exemple #4
0
        private IntPtr MouseHookProc(int nCode, WindowsMessagesFlags wParam, LowLevelMouseHookStruct lParam)
        {
            if (nCode >= 0)
            {
                if (this.LstHotKeys.SelectedItem is GenericHotkeyProxy hotkeyProxy &&
                    this.TxtSingleKey.IsFocused && Processes.IsCurrentProcessFocused())
                {
                    bool        validButton = false;
                    MouseAction mouseAction = 0;

                    var union = new Union32(lParam.mouseData);

                    if (wParam == WindowsMessagesFlags.WM_XBUTTONUP) // XButton
                    {
                        if (union.High == 0x0001)
                        {
                            validButton = true;
                            mouseAction = MouseAction.XButton1;
                        }
                        else if (union.High == 0x0002)
                        {
                            validButton = true;
                            mouseAction = MouseAction.XButton2;
                        }
                    }
                    else if (wParam == WindowsMessagesFlags.WM_MOUSEWHEEL) // MWheel
                    {
                        short delta = unchecked ((short)union.High);
                        if (delta > 0)
                        {
                            // MWheelUp
                            validButton = true;
                            mouseAction = MouseAction.MWheelUp;
                        }
                        else if (delta < 0)
                        {
                            // MWheelDown
                            validButton = true;
                            mouseAction = MouseAction.MWheelDown;
                        }
                    }

                    if (validButton && Enum.IsDefined(typeof(MouseAction), mouseAction))
                    {
                        this.UpdateHotkeyActivator(hotkeyProxy, HotkeyType.MouseHook, mouseAction, mouseAction.ToString());
                    }
                }
            }

            return(User32.CallNextHookEx(this.hHook, nCode, wParam, lParam));
        }
Exemple #5
0
 public static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode, WindowsMessagesFlags wParam, [In] LowLevelMouseHookStruct lParam);