Example #1
0
        public override Result Process(IntPtr wParam, WinAPI.MSLLHOOKSTRUCT llHookStruct, Properties.Settings settings)
        {
            if (WinAPI.MouseMessages.WM_XBUTTONUP == (WinAPI.MouseMessages)wParam)
            { // DOWN->NORMAL: middle button click
                var xbutton = GetXButton(llHookStruct.mouseData);

                if (!(settings.useX1 && xbutton == 1) && !(settings.useX2 && xbutton == 2))
                {
                    return(new Result(this));
                }

                if (!settings.emulateMiddleButton)
                {
                    return(new Result(new StateNormal(), CallNextHook.FALSE, null));
                }

                var input = InputMiddleClick(llHookStruct.pt);
                return(new Result(new StateNormal(), CallNextHook.FALSE, input));
            }
            else if (WinAPI.MouseMessages.WM_MOUSEMOVE == (WinAPI.MouseMessages)wParam)
            { // DOWN->SCROLL
                return(new Result(new StateScroll(Origin, 0, 0), CallNextHook.FALSE, null));
            }
            return(new Result(this));
        }
Example #2
0
 public abstract Result Process(IntPtr wParam, WinAPI.MSLLHOOKSTRUCT llHookStruct, Properties.Settings settings);
Example #3
0
        public override Result Process(IntPtr wParam, WinAPI.MSLLHOOKSTRUCT llHookStruct, Properties.Settings settings)
        {
            if (WinAPI.MouseMessages.WM_XBUTTONDOWN == (WinAPI.MouseMessages)wParam)
            { // NORMAL->DOWN: remember position
                var xbutton = GetXButton(llHookStruct.mouseData);
                if (!(settings.useX1 && xbutton == 1) && !(settings.useX2 && xbutton == 2))
                {
                    return(new Result(this));
                }

                return(new Result(new StateDown(llHookStruct.pt), CallNextHook.FALSE, null));
            }
            return(new Result(this));
        }
Example #4
0
        public override Result Process(IntPtr wParam, WinAPI.MSLLHOOKSTRUCT llHookStruct, Properties.Settings settings)
        {
            if (WinAPI.MouseMessages.WM_XBUTTONUP == (WinAPI.MouseMessages)wParam)
            { // SCROLL->NORMAL
                var xbutton = GetXButton(llHookStruct.mouseData);
                if (!(settings.useX1 && xbutton == 1) && !(settings.useX2 && xbutton == 2))
                {
                    return(new Result(this));
                }

                return(new Result(new StateNormal(), CallNextHook.FALSE, null));
            }

            WinAPI.INPUT[] input = null;

            if (WinAPI.MouseMessages.WM_MOUSEMOVE == (WinAPI.MouseMessages)wParam)
            { // SCROLL->SCROLL: wheel event
                int x = Xcount;
                int y = Ycount;

                if (Xcount < -X_THRESHOLD || Xcount > X_THRESHOLD)
                {
                    uint mouseData = (uint)((settings.reverseHorizontalScroll?-1:1) * WinAPI.WHEEL_DELTA * Xcount / X_THRESHOLD);
                    x = Xcount - (Xcount / X_THRESHOLD) * X_THRESHOLD; // integer division
                    if (settings.preferAxis)
                    {
                        y = 0;
                    }
                    input = InputWheel(llHookStruct.pt, mouseData, WinAPI.MouseEvent.MOUSEEVENTF_HWHEEL);
                }

                if (Ycount < -Y_THRESHOLD || Ycount > Y_THRESHOLD)
                {
                    uint mouseData = (uint)((settings.reverseVerticalScroll?1:-1) * WinAPI.WHEEL_DELTA * Ycount / Y_THRESHOLD);
                    if (settings.preferAxis)
                    {
                        x = 0;
                    }
                    y     = Ycount - (Ycount / Y_THRESHOLD) * Y_THRESHOLD; // integer division
                    input = InputWheel(llHookStruct.pt, mouseData, WinAPI.MouseEvent.MOUSEEVENTF_WHEEL);
                }

                x += llHookStruct.pt.x - Origin.x;
                y += llHookStruct.pt.y - Origin.y;

                return(new Result(new StateScroll(Origin, x, y), CallNextHook.FALSE, input));
            }

            return(new Result(this));
        }