Ejemplo n.º 1
0
        private IntPtr LeftClickHookCallBack(int nCode, IntPtr wParam, IntPtr lParam)
        {
            if (nCode >= 0 && (MouseMessages)wParam == MouseMessages.WM_LBUTTONDOWN)
            {
                this.timerTool.StartTimer();
                dispatcherTimer.Start();
            }

            if (nCode >= 0 && (MouseMessages)wParam == MouseMessages.WM_LBUTTONUP)
            {
                this.timerTool.StopTimer();
                dispatcherTimer.Stop();
            }

            return(MouseHook.CallNextHookEx(mouseHook.GetCurrentHookID(), nCode, wParam, lParam));
        }
Ejemplo n.º 2
0
        private IntPtr MouseHookCallBack(int nCode, IntPtr wParam, IntPtr lParam)
        {
            if (nCode >= 0 && (MouseMessages)wParam == MouseMessages.WM_RBUTTONDOWN)
            {
                if (this.targetWindowHandle == IntPtr.Zero)
                {
                    this.targetWindowHandle = this.autoLocation.GetForegroundWindowHandler();  //Set the target window
                }
                if (this.targetWindowHandle == this.autoLocation.GetForegroundWindowHandler()) //Only handle the target window
                {
                    var relativePos = this.autoLocation.GetClientCoordinates(this.targetWindowHandle);
                    var clientRect  = this.autoLocation.GetClientRect(this.targetWindowHandle);
                    var scaleX      = this.macroManager.GetCurrentMacro().OriginalX / clientRect.Width;
                    var scaleY      = this.macroManager.GetCurrentMacro().OriginalY / clientRect.Height;

                    SetLocationRecursive(this.macroManager.GetCurrentSelectedActionViewModel(), relativePos.X, scaleX, relativePos.Y, scaleY);
                }
            }

            return(MouseHook.CallNextHookEx(mouseHook.GetCurrentHookID(), nCode, wParam, lParam));
        }
Ejemplo n.º 3
0
        private IntPtr MouseHookCallBack(int nCode, IntPtr wParam, IntPtr lParam)
        {
            if (nCode >= 0 && (MouseMessages)wParam == MouseMessages.WM_RBUTTONDOWN)
            {
                if (this.targetWindowHandle == IntPtr.Zero)
                {
                    this.targetWindowHandle = this.autoLocation.GetForegroundWindowHandler();  //Set the target window
                }
                if (this.targetWindowHandle == this.autoLocation.GetForegroundWindowHandler()) //Only handle the target window
                {
                    var relativePos = this.autoLocation.GetClientCoordinates(this.targetWindowHandle);
                    var clientRect  = this.autoLocation.GetClientRect(this.targetWindowHandle);
                    var scaleX      = this.macroManager.GetCurrentMacro().OriginalX / clientRect.Width;
                    var scaleY      = this.macroManager.GetCurrentMacro().OriginalY / clientRect.Height;

                    if (this.macroManager.GetCurrentSelectedActionViewModel() is ILocationSettable selectedAction)
                    {
                        selectedAction.SetLocation(new Point(Math.Round(relativePos.X * scaleX, MidpointRounding.AwayFromZero), Math.Round(relativePos.Y * scaleY, MidpointRounding.AwayFromZero)));
                    }
                }
            }

            return(MouseHook.CallNextHookEx(mouseHook.GetCurrentHookID(), nCode, wParam, lParam));
        }