Пример #1
0
 private bool IsDoubleClick(MouseEventExtArgs e)
 {
     return
         e.Button == m_PreviousClicked &&
         e.Point == m_PreviousClickedPosition && // Click-move-click exception, see Patch 11222
         e.Timestamp - m_PreviousClickedTime <= m_SystemDoubleClickTime;
 }
Пример #2
0
 protected override void ProcessDown(ref MouseEventExtArgs e)
 {
     if (IsDoubleClick(e))
     {
         e = e.ToDoubleClickEventArgs();
     }
     base.ProcessDown(ref e);
 }
Пример #3
0
 private void GlobalEventProvider_MouseClickExt(object sender, MouseEventExtArgs e)
 {
     if (!this.Bounds.Contains(Cursor.Position))
     {
         e.Handled    = true;
         DialogResult = DialogResult.Cancel;
         Close();
     }
     else
     {
         SelectorPopup_HandleDestroyed(sender, e);
     }
 }
Пример #4
0
        protected override void ProcessUp(ref MouseEventExtArgs e)
        {
            base.ProcessUp(ref e);
            if (e.Clicks == 2)
            {
                StopDoubleClickWaiting();
            }

            if (e.Clicks == 1)
            {
                StartDoubleClickWaiting(e);
            }
        }
Пример #5
0
        private void M_GlobalHookOnMouseDownExt(object sender, MouseEventExtArgs e)
        {
            if (e.Button == MouseButtons.None)
            {
                return;
            }

            if ((e.Button == MouseButtons.Right && CurrentSetting.RightClick) ||
                (e.Button == MouseButtons.Left && CurrentSetting.LeftClick) || (e.Button == MouseButtons.XButton1 && CurrentSetting.XButton1) || (e.Button == MouseButtons.XButton2 && CurrentSetting.XButton2))
            {
                GenerateNew();
            }
        }
Пример #6
0
        private void M_GlobalHook_MouseMoveExt(object sender, MouseEventExtArgs e)
        {
            //set initial x and y coordinates
            initialXMouseLocation = isLocationSet ? initialXMouseLocation : e.X;
            initialYMouseLocation = isLocationSet ? initialYMouseLocation : e.Y;
            isLocationSet         = true;

            //check if mouse moved a significant distance, if it did, trigger event
            if (initialXMouseLocation > e.X + 200 || initialYMouseLocation > e.Y + 200 || initialXMouseLocation < e.X - 200 || initialYMouseLocation < e.Y - 200)
            {
                OnMouseMoved();
            }
        }
Пример #7
0
 private void GlobalHookMouseDownExt(object sender, MouseEventExtArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         lbl_lmb.ForeColor = Color.Green;
         lmbCPSCounter.click();
     }
     else if (e.Button == MouseButtons.Right)
     {
         lbl_rmb.ForeColor = Color.Green;
         rmbCPSCounter.click();
     }
 }
Пример #8
0
 public void GrabUnderCursor(object sender, MouseEventExtArgs e)
 {
     if (capture)
     {
         e.Handled = true;
         capture   = false;
         if (e.Button == MouseButtons.Left)
         {
             Color = GetPixel(MousePosition);
         }
         stateLabel.Text = waitingText;
     }
 }
Пример #9
0
        protected override void ProcessUp(ref MouseEventExtArgs e)
        {
            base.ProcessUp(ref e);
            if (e.Clicks == 2)
            {
                StopDoubleClickWaiting();
            }

            if (e.Clicks == 1)
            {
                StartDoubleClickWaiting(e);
            }
        }
Пример #10
0
 private static void HookManager_MouseDown(object sender, MouseEventExtArgs e)
 {
     isSwitcher = false;
     if (!(mouseStateMap.ContainsKey(e.Button) && mouseStateMap[e.Button]))
     {
         MouseChange(e, true);
         if (++countMousePressed > 6)
         {
             error = true;
         }
     }
     mouseStateMap[e.Button] = true;
 }
Пример #11
0
        private void GlobalHookMouseDownExt(object sender, MouseEventExtArgs e)
        {
            var foregroundProcess = GetForegroundWindow();
            var trackingProcess   = Process.GetProcessesByName(m_ApplcationName);

            foreach (Process p in trackingProcess)
            {
                if (foregroundProcess == p.MainWindowHandle)
                {
                    m_Actions++;
                }
            }
        }
        private void GlobalHook_MouseDownExt(object sender, MouseEventExtArgs e)
        {
            //if (e.Location.X > Left && e.Location.X <= Left + Width
            //    && e.Location.Y > Top && e.Location.Y <= Top + Height
            //    ) //does not work for Win10 - coordinates differ
            Point p = Mouse.GetPosition(this);

            if (p.X >= 0)//inside the window
            {
                return;
            }
            e.Handled = true;
            activate();
        }
        private void GlobalHookMouseDownExt(object sender, MouseEventExtArgs e)
        {
            //Set hWnd Label to the hWnd of the control clicked
            IntPtr hWnd = Win32.GetWindowHandleFromPoint(MousePosition.X, MousePosition.Y);

            lbl_hWnd.Text = hWnd.ToString();
            //Set txt_PasswordBoxTitle to the title of the password box window.
            txt_PasswordBoxTitle.Text = Win32.GetWindowTitle(hWnd);
            // Set the Textbox to the title of the parent window.
            txt_ParentTitle.Text = Win32.GetWindowTitle(Win32.getAbsoluteParent(hWnd));
            //Unsubscribe / Deactivate the system hook
            Unsubscribe();
            hookSubscribe = false;
        }
        private void GlobalHookMouseDownExt(object sender, MouseEventExtArgs e)     //Immer wenn Maus geklickt
        {
            maus++;
            tbAnzahlMouse.Text = maus.ToString();
            zeichenspeichercounter_maus++;

            if (zeichenspeichercounter_maus == 5)            //Speichert bei jeder fünften Mauseingabe
            {
                StreamWriter speichern_maus = new StreamWriter(@"speichere_wert_maus.txt");
                speichern_maus.WriteLine(maus.ToString());
                speichern_maus.Close();
                zeichenspeichercounter_maus = 0;
            }
        }
Пример #15
0
 private void GlobalHookMouseMove(object sender, MouseEventExtArgs e)
 {
     using (var bitmap = new Bitmap(1, 1))
     {
         using (var graphics = Graphics.FromImage(bitmap))
         {
             graphics.CopyFromScreen(new Point(e.X, e.Y), new Point(0, 0), new Size(1, 1));
         }
         var pixel = bitmap.GetPixel(0, 0);
         SelectorModel.Red   = pixel.R;
         SelectorModel.Blue  = pixel.B;
         SelectorModel.Green = pixel.G;
     }
 }
Пример #16
0
        //when mouse key is pressed
        private void GlobalHookMouseDownExt(object sender, MouseEventExtArgs e)
        {
            if (e.Button != MouseButtons.Left && e.Button != MouseButtons.Right && e.Button != MouseButtons.None)
            {
                TimeSpan ts        = stopwatch.Elapsed;
                string   timestamp = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                                                   ts.Hours, ts.Minutes, ts.Seconds,
                                                   ts.Milliseconds / 10);
                //save time to file
                fileHandler.writeToFile(timestamp + "\n");

                this.timePassLbl.Text = timestamp;
            }
        }
Пример #17
0
        private void KeyboardMouseEvents_MouseDownExt(object sender, MouseEventExtArgs e)
        {
            Vector2 mousePosition = GameController.Window.ScreenToClient(e.X, e.Y);

            if (isPoeGameVisible)
            {
                if (Settings.ShowMenuButton && MenuToggleButtonRect.Contains(mousePosition))
                {
                    Settings.Enable.Value = !Settings.Enable.Value;
                    e.Handled             = true;
                    return;
                }
            }

            var io = ImGui.GetIO();

            io.MousePosition = new System.Numerics.Vector2(mousePosition.X, mousePosition.Y);

            if (ImGuiWantCaptureMouse(io))
            {
                switch (e.Button)
                {
                case MouseButtons.Left:
                    io.MouseDown[0] = true;
                    e.Handled       = true;
                    break;

                case MouseButtons.Right:
                    io.MouseDown[1] = true;
                    e.Handled       = true;
                    break;

                case MouseButtons.Middle:
                    io.MouseDown[2] = true;
                    e.Handled       = true;
                    break;

                case MouseButtons.XButton1:
                    io.MouseDown[3] = true;
                    e.Handled       = true;
                    break;

                case MouseButtons.XButton2:
                    io.MouseDown[4] = true;
                    e.Handled       = true;
                    break;
                }
            }
        }
Пример #18
0
 private void HookManager_MouseWheelExt(object sender, MouseEventExtArgs e)
 {
     if (WIN() && CTRL())
     {
         if (e.Delta > 0)
         {
             SendKeys.Send("{RIGHT}");
         }
         else
         {
             SendKeys.Send("{LEFT}");
         }
         e.Handled = true;
     }
 }
Пример #19
0
        private void GlobalHookMouseUpExt(object sender, MouseEventExtArgs e)
        {
            if (Monitor.GetTopWindowText() == "")
            {
                foreach (NanoD2d control in MouseDownList)
                {
                    if (control is IMouseUp clickableControl)
                    {
                        clickableControl.OnMouseUp(sender, e);
                    }
                }
            }

            MouseDownList.Clear();
        }
Пример #20
0
        private void GlobalHook_MouseDragFinishedExt(object sender, MouseEventExtArgs e)
        {
            var delayTimer = new DispatcherTimer
            {
                Interval = TimeSpan.FromMilliseconds(10)
            };

            delayTimer.Tick += (tS, tE) =>
            {
                ShellUtility.SetTranspernt(this, false);
                delayTimer.Stop();
            };

            delayTimer.Start();
        }
Пример #21
0
        private void ProcessDragStarted(ref MouseEventExtArgs e)
        {
            if (!m_IsDragging)
            {
                var isXDragging = Math.Abs(e.Point.X - m_DragStartPosition.X) > m_xDragThreshold;
                var isYDragging = Math.Abs(e.Point.Y - m_DragStartPosition.Y) > m_yDragThreshold;
                m_IsDragging = isXDragging || isYDragging;

                if (m_IsDragging)
                {
                    OnDragStarted(e);
                    OnDragStartedExt(e);
                }
            }
        }
Пример #22
0
        private void HookMouseWheelExt(object sender, MouseEventExtArgs e)
        {
            if (!this.enable)
            {
                return;
            }

            ImGuiIOPtr io = ImGui.GetIO();

            if (io.WantCaptureMouse)
            {
                io.MouseWheel = e.Delta / SystemInformation.MouseWheelScrollDelta;
                e.Handled     = true;
            }
        }
Пример #23
0
        private void GlobalHook_MouseDownExt(object sender, MouseEventExtArgs e)
        {
            if (e.Clicks == 2)
            {
                Globals.ThisAddIn.TheWindowsFormsSynchronizationContext.Send(d =>
                {
                    if (SelectedShape != null)
                    {
                        EditDiagramShape(SelectedShape);
                    }
                }, null);

                e.Handled = true;
            }
        }
Пример #24
0
        private static void GlobalHookMouseScrollHandler(object sender, MouseEventExtArgs e)
        {
            if (!TradeClient.IsReady || !ProcessHelper.IsPathOfExileInFocus())
            {
                return;
            }

            // Ctrl + Scroll wheel to move between stash tabs.
            if ((System.Windows.Input.Keyboard.Modifiers & System.Windows.Input.ModifierKeys.Control) > 0)
            {
                e.Handled = true;
                string key = e.Delta > 0 ? "{LEFT}" : "{RIGHT}";
                SendKeys.Send(key);
            }
        }
Пример #25
0
        //private void GlobalHookKeyPress(object sender, KeyPressEventArgs e)
        //{
        //    Console.WriteLine("KeyPress: \t{0}", e.KeyChar);
        //}

        private void GlobalHookMouseDownExt(object sender, MouseEventExtArgs e)
        {
            Console.WriteLine("MouseDown: \t{0}; \t System Timestamp: \t{1}", e.Button, e.Timestamp);

            if (e.Button == toggleDefault)
            {
                unmuteMic();
                e.Handled = true;
            }

            //if (e.Button == unmuteDefault)
            //{
            //    unmuteMic();
            //    e.Handled = true;
            //}
        }
Пример #26
0
        void SharpDXComboValue_MouseClickEventUp(object sender, MouseEventExtArgs e)
        {
            Vector2 location = this.GetAbsoluteLocation();
            Vector2 size     = this.GetSize();

            Vector2 clickPoint = (Vector2)e.PosOnForm - location;

            if (clickPoint.X < size.X / 2f)
            {
                this.SelectedIndex--;
            }
            else
            {
                this.SelectedIndex++;
            }
        }
Пример #27
0
        private void KeyboardMouseEvents_MouseUpExt(object sender, MouseEventExtArgs e)
        {
            if (!Settings.Enable)
            {
                return;
            }

            if (e.Button == MouseButtons.Left)
            {
                if (bMouse_Drag)
                {
                    bMouse_Drag = false;
                    e.Handled   = true;
                }
            }
        }
Пример #28
0
        private void Hook_MouseWheelExt(object sender, MouseEventExtArgs e)
        {
            if (!nativeProcess.IsPathOfExileInFocus || !settings.Stash_EnableCtrlScroll || !IsCtrlPressed())
            {
                return;
            }

            if (e.Delta > 0)
            {
                e.Handled = OnScrollUp?.Invoke() ?? false;
            }
            else
            {
                e.Handled = OnScrollDown?.Invoke() ?? false;
            }
        }
Пример #29
0
 void MouseMove(object sender, MouseEventExtArgs e)
 {
     if (isActive)
     {
         shield.Location = new Point(e.Location.X - CursorPadding, e.Location.Y - CursorPadding);
         secondPoint     = e.Location;
         var r = Rectangle.FromLTRB(
             Math.Min(firstPoint.X, secondPoint.X),
             Math.Min(firstPoint.Y, secondPoint.Y),
             Math.Max(firstPoint.X, secondPoint.X),
             Math.Max(firstPoint.Y, secondPoint.Y)
             );
         regionSelector.Location = r.Location;
         regionSelector.Size     = r.Size;
     }
 }
Пример #30
0
        private void ProcessMouseUpDown(MouseEventExtArgs e, bool isDownEvent, bool shouldSendToImGui)
        {
            ImGuiIOPtr io = ImGui.GetIO();

            if (shouldSendToImGui)
            {
                switch (e.Button)
                {
                case MouseButtons.Left:
                    io.MouseDown[0] = isDownEvent;
                    break;

                case MouseButtons.Right:
                    io.MouseDown[1] = isDownEvent;
                    break;

                case MouseButtons.Middle:
                    io.MouseDown[2] = isDownEvent;
                    break;

                case MouseButtons.XButton1:
                    io.MouseDown[3] = isDownEvent;
                    break;

                case MouseButtons.XButton2:
                    io.MouseDown[4] = isDownEvent;
                    break;

                case MouseButtons.None:
                    // TODO: Find out what does this None mean
                    break;

                default:
                    // TODO: Make a Logger for the whole Overlay
                    break;
                }
            }
            else
            {
                this.PushMessage(HookControllerMessageType.MouseUpDown, e, isDownEvent);
            }

            if (io.WantCaptureMouse)
            {
                e.Handled = true;
            }
        }
Пример #31
0
        private Win32.WinDocPos isInWindow(MouseEventExtArgs e)
        {
            int X = e.X;
            int Y = e.Y;

            if ((X > Left && X < Width + Left) && (Y > Top && Y < Top + Height))
            {                                                                                                        // in window
                int space = 15;
                if ((X > Left + space && X < Width + Left - space) && (Y > Top + space && Y < Top + Height - space)) // main
                {
                    return(Win32.WinDocPos.main);
                }
                else if ((X > Left && X < Left + space) && (Y > Top + space && Y < Top + Height - space))// left
                {
                    return(Win32.WinDocPos.Left);
                }
                else if ((X > Left + space && X < Width + Left - space) && (Y > Top && Y < Top + space))// Top
                {
                    return(Win32.WinDocPos.Top);
                }
                else if ((X > Width + Left - space && X < Width + Left) && (Y > Top + space && Y < Top + Height - space))// right
                {
                    return(Win32.WinDocPos.Right);
                }
                else if ((X > Left + space && X < Width + Left - space) && (Y > Top + Height - space && Y < Top + Height))// bottom
                {
                    return(Win32.WinDocPos.Bottom);
                }
                else if ((X > Left && X < Left + space) && (Y > Top && Y < Top + space))// TopLeft
                {
                    return(Win32.WinDocPos.TopLeft);
                }
                else if ((X > Left + Width - space && X < Width + Left) && (Y > Top && Y < Top + space))// TopRight
                {
                    return(Win32.WinDocPos.TopRight);
                }
                else if ((X > Left + Width - space && X < Width + Left) && (Y > Top + Height - space && Y < Top + Height))// BottomRight
                {
                    return(Win32.WinDocPos.BottomRight);
                }
                else if ((X > Left && X < Left + space) && (Y > Top + Height - space && Y < Top + Height))// BottomLeft
                {
                    return(Win32.WinDocPos.BottomLeft);
                }
            }
            return(Win32.WinDocPos.outOfWindow);
        }
Пример #32
0
 // Token: 0x0600028B RID: 651 RVA: 0x0000E29C File Offset: 0x0000C49C
 protected virtual void ProcessDown(ref MouseEventExtArgs e)
 {
     this.OnDown(e);
     this.OnDownExt(e);
     if (e.Handled)
     {
         return;
     }
     if (e.Clicks == 2)
     {
         this.m_DoubleDown.Add(e.Button);
     }
     if (e.Clicks == 1)
     {
         this.m_SingleDown.Add(e.Button);
     }
 }
Пример #33
0
        private void ProcessDrag(ref MouseEventExtArgs e)
        {
            if (m_SingleDown.Contains(MouseButtons.Left))
            {
                if (m_DragStartPosition.Equals(m_UninitialisedPoint))
                {
                    m_DragStartPosition = e.Point;
                }

                ProcessDragStarted(ref e);
            }
            else
            {
                m_DragStartPosition = m_UninitialisedPoint;
                ProcessDragFinished(ref e);
            }
        }
Пример #34
0
        protected virtual void ProcessDown(ref MouseEventExtArgs e)
        {
            OnDown(e);
            OnDownExt(e);
            if (e.Handled)
            {
                return;
            }

            if (e.Clicks == 2)
            {
                m_DoubleDown.Add(e.Button);
            }

            if (e.Clicks == 1)
            {
                m_SingleDown.Add(e.Button);
            }
        }
Пример #35
0
        protected virtual void ProcessUp(ref MouseEventExtArgs e)
        {
            if (m_SingleDown.Contains(e.Button))
            {
                OnUp(e);
                OnUpExt(e);
                if (e.Handled)
                {
                    return;
                }
                OnClick(e);
                m_SingleDown.Remove(e.Button);
            }

            if (m_DoubleDown.Contains(e.Button))
            {
                e = e.ToDoubleClickEventArgs();
                OnUp(e);
                OnDoubleClick(e);
                m_DoubleDown.Remove(e.Button);
            }
        }
Пример #36
0
        /// <summary>A callback function which will be called every Time a mouse activity detected.</summary>
        /// <param name="nCode">Specifies whether the hook procedure must process the message. If nCode is HC_ACTION, the hook procedure must process the message. 
        /// If nCode is less than zero, the hook procedure must pass the message to the CallNextHookEx function without further processing and must return the value returned by CallNextHookEx.</param>
        /// <param name="wParam">Specifies whether the message was sent by the current thread. If the message was sent by the current thread, it is nonzero; otherwise, it is zero.</param>       
        /// <param name="lParam">Pointer to a CWPSTRUCT structure that contains details about the message.</param>
        /// <returns>If nCode is less than zero, the hook procedure must return the value returned by CallNextHookEx. If nCode is greater than or equal to zero, it is highly recommended that you call CallNextHookEx 
        /// and return the value it returns; otherwise, other applications that have installed WH_CALLWNDPROC hooks will not receive hook notifications and may behave incorrectly as a result. If the hook 
        /// procedure does not call CallNextHookEx, the return value should be zero.</returns>
        private static int MouseHookProc(int nCode, int wParam, IntPtr lParam)
        {
            if (nCode >= 0)
            {
                //Marshall the data from callback.
                MouseLLHookStruct mouseHookStruct = (MouseLLHookStruct)Marshal.PtrToStructure(lParam, typeof(MouseLLHookStruct));

                //detect button clicked
                MouseButtons button = MouseButtons.None;
                short mouseDelta = 0;
                int clickCount = 0;

                //generate event
                MouseEventExtArgs e = new MouseEventExtArgs(button, clickCount, mouseHookStruct.Point.X, mouseHookStruct.Point.Y, mouseDelta);

                //If someone listens to move and there was a change in coordinates raise move event
                if ((s_MouseMove != null) && (m_OldX != mouseHookStruct.Point.X || m_OldY != mouseHookStruct.Point.Y))
                {
                    m_OldX = mouseHookStruct.Point.X;
                    m_OldY = mouseHookStruct.Point.Y;
                    if (s_MouseMove != null)
                    {
                        s_MouseMove.Invoke(null, e);
                    }
                }

                if (e.Handled)
                {
                    return -1;
                }
            }

            //call next hook
            return CallNextHookEx(s_MouseHookHandle, nCode, wParam, lParam);
        }
Пример #37
0
        /// <summary>
        /// A callback function which will be called every Time a mouse activity detected.
        /// </summary>
        /// <param name="nCode">
        /// [in] Specifies whether the hook procedure must process the message.
        /// If nCode is HC_ACTION, the hook procedure must process the message.
        /// If nCode is less than zero, the hook procedure must pass the message to the
        /// CallNextHookEx function without further processing and must return the
        /// value returned by CallNextHookEx.
        /// </param>
        /// <param name="wParam">
        /// [in] Specifies whether the message was sent by the current thread.
        /// If the message was sent by the current thread, it is nonzero; otherwise, it is zero.
        /// </param>
        /// <param name="lParam">
        /// [in] Pointer to a CWPSTRUCT structure that contains details about the message.
        /// </param>
        /// <returns>
        /// If nCode is less than zero, the hook procedure must return the value returned by CallNextHookEx.
        /// If nCode is greater than or equal to zero, it is highly recommended that you call CallNextHookEx
        /// and return the value it returns; otherwise, other applications that have installed WH_CALLWNDPROC
        /// hooks will not receive hook notifications and may behave incorrectly as a result. If the hook
        /// procedure does not call CallNextHookEx, the return value should be zero.
        /// </returns>
        private static int MouseHookProc(int nCode, int wParam, IntPtr lParam)
        {
            if (nCode >= 0)
            {
                //Marshall the data from callback.
                MouseLLHookStruct mouseHookStruct = (MouseLLHookStruct)Marshal.PtrToStructure(lParam, typeof(MouseLLHookStruct));

                //detect button clicked
                MouseButtons button = MouseButtons.None;
                short mouseDelta = 0;
                int clickCount = 0;
                bool mouseDown = false;
                bool mouseUp = false;

                switch (wParam)
                {
                    case WM_LBUTTONDOWN:
                        mouseDown = true;
                        button = MouseButtons.Left;
                        clickCount = 1;
                        break;
                    case WM_LBUTTONUP:
                        mouseUp = true;
                        button = MouseButtons.Left;
                        clickCount = 1;
                        break;
                    case WM_LBUTTONDBLCLK:
                        button = MouseButtons.Left;
                        clickCount = 2;
                        break;
                    case WM_RBUTTONDOWN:
                        mouseDown = true;
                        button = MouseButtons.Right;
                        clickCount = 1;
                        break;
                    case WM_RBUTTONUP:
                        mouseUp = true;
                        button = MouseButtons.Right;
                        clickCount = 1;
                        break;
                    case WM_RBUTTONDBLCLK:
                        button = MouseButtons.Right;
                        clickCount = 2;
                        break;
                    case WM_MOUSEWHEEL:
                        //If the message is WM_MOUSEWHEEL, the high-order word of MouseData member is the wheel delta.
                        //One wheel click is defined as WHEEL_DELTA, which is 120.
                        //(value >> 16) & 0xffff; retrieves the high-order word from the given 32-bit value
                        mouseDelta = (short)((mouseHookStruct.MouseData >> 16) & 0xffff);

                        //TODO: X BUTTONS (I havent them so was unable to test)
                        //If the message is WM_XBUTTONDOWN, WM_XBUTTONUP, WM_XBUTTONDBLCLK, WM_NCXBUTTONDOWN, WM_NCXBUTTONUP,
                        //or WM_NCXBUTTONDBLCLK, the high-order word specifies which X button was pressed or released,
                        //and the low-order word is reserved. This value can be one or more of the following values.
                        //Otherwise, MouseData is not used.
                        break;
                }

                //generate event
                MouseEventExtArgs e = new MouseEventExtArgs(
                                                   button,
                                                   clickCount,
                                                   mouseHookStruct.Point.X,
                                                   mouseHookStruct.Point.Y,
                                                   mouseDelta);

                //Mouse up
                if (s_MouseUp != null && mouseUp)
                {
                    s_MouseUp.Invoke(null, e);
                }

                //Mouse down
                if (s_MouseDown != null && mouseDown)
                {
                    s_MouseDown.Invoke(null, e);
                }

                //If someone listens to click and a click is heppened
                if (s_MouseClick != null && clickCount > 0)
                {
                    s_MouseClick.Invoke(null, e);
                }

                //If someone listens to click and a click is heppened
                if (s_MouseClickExt != null && clickCount > 0)
                {
                    s_MouseClickExt.Invoke(null, e);
                }

                //If someone listens to double click and a click is heppened
                if (s_MouseDoubleClick != null && clickCount == 2)
                {
                    s_MouseDoubleClick.Invoke(null, e);
                }

                //Wheel was moved
                if (s_MouseWheel != null && mouseDelta != 0)
                {
                    s_MouseWheel.Invoke(null, e);
                }

                //If someone listens to move and there was a change in coordinates raise move event
                if ((s_MouseMove != null || s_MouseMoveExt != null) && (m_OldX != mouseHookStruct.Point.X || m_OldY != mouseHookStruct.Point.Y))
                {
                    m_OldX = mouseHookStruct.Point.X;
                    m_OldY = mouseHookStruct.Point.Y;
                    if (s_MouseMove != null)
                    {
                        s_MouseMove.Invoke(null, e);
                    }

                    if (s_MouseMoveExt != null)
                    {
                        s_MouseMoveExt.Invoke(null, e);
                    }
                }

                if (e.Handled)
                {
                    return -1;
                }
            }

            //call next hook
            return CallNextHookEx(s_MouseHookHandle, nCode, wParam, lParam);
        }
Пример #38
0
 private void HookManager_Supress(object sender, MouseEventExtArgs e)
 {
 }
Пример #39
0
 private void StartDoubleClickWaiting(MouseEventExtArgs e)
 {
     m_PreviousClicked = e.Button;
     m_PreviousClickedTime = e.Timestamp;
     m_PreviousClickedPosition = e.Point;
 }
Пример #40
0
        private void ProcessDrag(ref MouseEventExtArgs e)
        {
            if (m_SingleDown.Contains(MouseButtons.Left))
            {
                if (m_DragStartPosition.Equals(m_UninitialisedPoint))
                {
                    m_DragStartPosition = e.Point;
                }

                ProcessDragStarted(ref e);
            }
            else
            {
                m_DragStartPosition = m_UninitialisedPoint;
                ProcessDragFinished(ref e);
            }
        }
Пример #41
0
        private void ProcessDragStarted(ref MouseEventExtArgs e)
        {
            if (!m_IsDragging)
            {
                var isXDragging = Math.Abs(e.Point.X - m_DragStartPosition.X) > m_xDragThreshold;
                var isYDragging = Math.Abs(e.Point.Y - m_DragStartPosition.Y) > m_yDragThreshold;
                m_IsDragging = isXDragging || isYDragging;

                if (m_IsDragging)
                {
                    OnDragStarted(e);
                    OnDragStartedExt(e);
                }
            }
        }
Пример #42
0
 void HookManager_MouseMoveExt(object sender, MouseEventExtArgs e)
 {
     if (m_MouseMoveExt != null)
     {
         RaiseEventOnUIThread(m_MouseMoveExt, e);
     }
 }
Пример #43
0
 private void ProcessDragFinished(ref MouseEventExtArgs e)
 {
     if (m_IsDragging)
     {
         OnDragFinished(e);
         OnDragFinishedExt(e);
         m_IsDragging = false;
     }
 }
Пример #44
0
        private static int MouseHookProc(int nCode, int wParam, IntPtr lParam)
        {
            if (nCode >= 0)
            {
                //Marshall the data from callback.
                var mouseHookStruct = (MouseLLHookStruct) Marshal.PtrToStructure(lParam, typeof(MouseLLHookStruct));

                //detect button clicked
                var button = MouseButtons.None;
                short mouseDelta = 0;
                var clickCount = 0;
                var mouseDown = false;
                var mouseUp = false;

                switch (wParam)
                {
                    case WM_LBUTTONDOWN:
                        mouseDown = true;
                        button = MouseButtons.Left;
                        clickCount = 1;
                        break;
                    case WM_LBUTTONUP:
                        mouseUp = true;
                        button = MouseButtons.Left;
                        clickCount = 1;
                        break;
                    case WM_LBUTTONDBLCLK:
                        button = MouseButtons.Left;
                        clickCount = 2;
                        break;
                    case WM_RBUTTONDOWN:
                        mouseDown = true;
                        button = MouseButtons.Right;
                        clickCount = 1;
                        break;
                    case WM_RBUTTONUP:
                        mouseUp = true;
                        button = MouseButtons.Right;
                        clickCount = 1;
                        break;
                    case WM_RBUTTONDBLCLK:
                        button = MouseButtons.Right;
                        clickCount = 2;
                        break;
                    case WM_MOUSEWHEEL:
                        //If the message is WM_MOUSEWHEEL, the high-order word of MouseData member is the wheel delta.
                        //One wheel click is defined as WHEEL_DELTA, which is 120.
                        //(value >> 16) & 0xffff; retrieves the high-order word from the given 32-bit value
                        mouseDelta = (short) ((mouseHookStruct.MouseData >> 16) & 0xffff);
                        break;
                }

                //generate event
                var e = new MouseEventExtArgs(
                    button,
                    clickCount,
                    mouseHookStruct.Point.X,
                    mouseHookStruct.Point.Y,
                    mouseDelta);

                //Mouse up
                if (s_MouseUp != null && mouseUp)
                {
                    s_MouseUp.Invoke(null, e);
                }

                //Mouse down
                if (s_MouseDown != null && mouseDown)
                {
                    s_MouseDown.Invoke(null, e);
                }

                //If someone listens to click and a click is heppened
                if (s_MouseClick != null && clickCount > 0)
                {
                    s_MouseClick.Invoke(null, e);
                }

                //If someone listens to click and a click is heppened
                if (s_MouseClickExt != null && clickCount > 0)
                {
                    s_MouseClickExt.Invoke(null, e);
                }

                //If someone listens to double click and a click is heppened
                if (s_MouseDoubleClick != null && clickCount == 2)
                {
                    s_MouseDoubleClick.Invoke(null, e);
                }

                //Wheel was moved
                if (s_MouseWheel != null && mouseDelta != 0)
                {
                    s_MouseWheel.Invoke(null, e);
                }

                //If someone listens to move and there was a change in coordinates raise move event
                if ((s_MouseMove != null || s_MouseMoveExt != null) && (m_OldX != mouseHookStruct.Point.X || m_OldY != mouseHookStruct.Point.Y))
                {
                    m_OldX = mouseHookStruct.Point.X;
                    m_OldY = mouseHookStruct.Point.Y;
                    s_MouseMove?.Invoke(null, e);

                    s_MouseMoveExt?.Invoke(null, e);
                }

                if (e.Handled)
                {
                    return -1;
                }
            }

            //call next hook
            return CallNextHookEx(s_MouseHookHandle, nCode, wParam, lParam);
        }
Пример #45
0
 protected virtual void OnDragFinishedExt(MouseEventExtArgs e)
 {
     var handler = MouseDragFinishedExt;
     if (handler != null) handler(this, e);
 }
Пример #46
0
 protected virtual void OnUpExt(MouseEventExtArgs e)
 {
     var handler = MouseUpExt;
     if (handler != null) handler(this, e);
 }
Пример #47
0
        private void ProcessMove(ref MouseEventExtArgs e)
        {
            m_PreviousPosition = e.Point;

            OnMove(e);
            OnMoveExt(e);
        }
Пример #48
0
 protected virtual void ProcessWheel(ref MouseEventExtArgs e)
 {
     OnWheel(e);
 }
Пример #49
0
 private void HookManager_Supress(object sender, MouseEventExtArgs e)
 {
     if (e.Button != MouseButtons.Right) { return;}
     Log("Suppressed.\n");
     e.Handled = true;
 }
Пример #50
0
 private void HookManager_MouseMoveExt(object sender, MouseEventExtArgs e)
 {
     if (m_MouseMoveExt != null)
     {
         m_MouseMoveExt.Invoke(this, e);
     }
 }