예제 #1
0
 private void MouseEvents_MouseDownExt(object sender, MouseHook.MouseEventExtArgs e)
 {
     Loger.LogMouseItems.Add(new LogMouseItem()
     {
         Date = DateTime.Now, Event = e.Button.ToString(), x = e.Location.X, y = e.Location.Y
     });
 }
예제 #2
0
        private void GlobalHookMouseDownExt(object sender, MouseEventExtArgs e)
        {
            Console.WriteLine("MouseDown: \t{0}; \t System Timestamp: \t{1}", e.Button, e.Timestamp);

            // uncommenting the following line will suppress the middle mouse button click
            // if (e.Buttons == MouseButtons.Middle) { e.Handled = true; }
        }
예제 #3
0
 private void M_AppHook_MouseDownExt( object sender, MouseEventExtArgs e ) {
     if ( e.Button == MouseButtons.Middle ) {
         MouseDownLocation = Mouse.GetPosition( this );
         m_AppHook.MouseMoveExt += M_AppHook_MouseMoveExt;
         e.Handled = true;
     }
 }
예제 #4
0
 private void M_Hook_MouseMoveExt(object sender, MouseEventExtArgs e)
 {
     if (null != m_MoveAction)
     {
         m_MoveAction(e);
     }
 }
예제 #5
0
 private void M_AppHook_MouseMoveExt( object sender, MouseEventExtArgs e ) {
     if ( Mouse.MiddleButton == MouseButtonState.Pressed ) {
         Left = ( e.X - MouseDownLocation.X );
         Top = ( e.Y - MouseDownLocation.Y );
         e.Handled = true;
     } else m_AppHook.MouseMoveExt -= M_AppHook_MouseMoveExt;
 }
예제 #6
0
 static void M_events_MouseMove(object sender, MouseEventExtArgs e)
 {
     if (transmitMouse)
     {
         com.SendMove(e.X, e.Y);
         f.SetColor();
         f.Location = new Point(e.X - f.Width / 2, e.Y - f.Height / 2);
     }
 }
예제 #7
0
        private void GlobalHookMouseUpExt(object sender, MouseEventExtArgs e)
        {
            Console.WriteLine("MouseUp: \t{0}; \t System Timestamp: \t{1}; \t X: \t{2}; \t Y: \t{3}", e.Button, e.Timestamp, e.Location.X, e.Location.Y);
            p2 = e.Location;

            Unsubscribe();

            //ImageSource imageSource = new BitmapImage(new Uri("C:\\Users\\Brendan\\Downloads\\Clockwerk.png"));
            //TestImage.Source = imageSource;
            //GrabScreen();
            ScreenCap();
        }
        /// <summary>
        ///     Creates <see cref="MouseEventExtArgs" /> from relevant mouse data.
        /// </summary>
        /// <param name="wParam">First Windows Message parameter.</param>
        /// <param name="mouseInfo">A MouseStruct containing information from which to construct MouseEventExtArgs.</param>
        /// <returns>A new MouseEventExtArgs object.</returns>
        private static MouseEventExtArgs FromRawDataUniversal(IntPtr wParam, MouseStruct mouseInfo)
        {
            var   button     = MouseButtons.None;
            short mouseDelta = 0;
            var   clickCount = 0;

            var isMouseButtonDown = false;
            var isMouseButtonUp   = false;


            switch ((long)wParam)
            {
            case Messages.WM_LBUTTONDOWN:
                isMouseButtonDown = true;
                button            = MouseButtons.Left;
                clickCount        = 1;
                break;

            case Messages.WM_LBUTTONUP:
                isMouseButtonUp = true;
                button          = MouseButtons.Left;
                clickCount      = 1;
                break;

            case Messages.WM_LBUTTONDBLCLK:
                isMouseButtonDown = true;
                button            = MouseButtons.Left;
                clickCount        = 2;
                break;

            case Messages.WM_RBUTTONDOWN:
                isMouseButtonDown = true;
                button            = MouseButtons.Right;
                clickCount        = 1;
                break;

            case Messages.WM_RBUTTONUP:
                isMouseButtonUp = true;
                button          = MouseButtons.Right;
                clickCount      = 1;
                break;

            case Messages.WM_RBUTTONDBLCLK:
                isMouseButtonDown = true;
                button            = MouseButtons.Right;
                clickCount        = 2;
                break;

            case Messages.WM_MBUTTONDOWN:
                isMouseButtonDown = true;
                button            = MouseButtons.Middle;
                clickCount        = 1;
                break;

            case Messages.WM_MBUTTONUP:
                isMouseButtonUp = true;
                button          = MouseButtons.Middle;
                clickCount      = 1;
                break;

            case Messages.WM_MBUTTONDBLCLK:
                isMouseButtonDown = true;
                button            = MouseButtons.Middle;
                clickCount        = 2;
                break;

            case Messages.WM_MOUSEWHEEL:
                mouseDelta = mouseInfo.MouseData;
                break;

            case Messages.WM_XBUTTONDOWN:
                button = mouseInfo.MouseData == 1
                        ? MouseButtons.XButton1
                        : MouseButtons.XButton2;
                isMouseButtonDown = true;
                clickCount        = 1;
                break;

            case Messages.WM_XBUTTONUP:
                button = mouseInfo.MouseData == 1
                        ? MouseButtons.XButton1
                        : MouseButtons.XButton2;
                isMouseButtonUp = true;
                clickCount      = 1;
                break;

            case Messages.WM_XBUTTONDBLCLK:
                isMouseButtonDown = true;
                button            = mouseInfo.MouseData == 1
                        ? MouseButtons.XButton1
                        : MouseButtons.XButton2;
                clickCount = 2;
                break;

            case Messages.WM_MOUSEHWHEEL:
                mouseDelta = mouseInfo.MouseData;
                break;
            }

            var e = new MouseEventExtArgs(
                button,
                clickCount,
                mouseInfo.Point,
                mouseDelta,
                mouseInfo.Timestamp,
                isMouseButtonDown,
                isMouseButtonUp);

            return(e);
        }
예제 #9
0
 private void M_Hook_MouseDownExt(object sender, MouseEventExtArgs e)
 {
 }
예제 #10
0
        private void GlobalHookMouseDownExt(object sender, MouseEventExtArgs e)
        {
            //Get window from mouseclick point
            IntPtr windowHandle = WindowFromPoint(new InvokeStructs.POINT(e.X, e.Y));
            if (windowHandle == IntPtr.Zero) return;

            //Loop processes to find matching MainWindowHandle
            Process process = GetProcessFromHandle(windowHandle);
            if (process == null || process.MainWindowTitle == "WindowStay") return;

            //Get rectangle of found window
            try
            {
                InvokeStructs.RECT rect = GetWindowRectFromHandle(windowHandle);
                Window = new ProgramWindow(process.MainWindowTitle, rect);
                Notify();
            }
            catch (Exception exception)
            {
                Debug.WriteLine(exception);
            }
        }
예제 #11
0
 /// <summary>
 /// Mouse Movement event. Save it to a temp list to only save it ever x seconds to the database 
 /// (see Settings.MouseSnapshotInterval) to reduce the data load.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private static async void MouseListener_MouseMoveExt(object sender, MouseEventExtArgs e)
 {
     await Task.Run(() =>
     {
         MouseMovementBuffer.Enqueue(new MouseMovementSnapshot(e));
         MouseMovement?.Invoke(new MouseMovementSnapshot(e));
     });
 }
예제 #12
0
        private void HookManager_Supress(object sender, MouseEventExtArgs e)
        {
            if (e.Button != MouseButtons.Right)
            {
                Log(string.Format("MouseDown \t\t {0}\n", e.Button));
                return;
            }

            Log(string.Format("MouseDown \t\t {0} Suppressed\n", e.Button));
            e.Handled = true;
        }
예제 #13
0
 private void HookManager_MouseWheelExt(object sender, MouseEventExtArgs e)
 {
     labelWheel.Text = string.Format("Wheel={0:000}", e.Delta);
     Log("Mouse Wheel Move Suppressed.\n");
     e.Handled = true;
 }
예제 #14
0
        /// <summary>
        ///     Creates <see cref="MouseEventExtArgs" /> from relevant mouse data.
        /// </summary>
        /// <param name="wParam">First Windows Message parameter.</param>
        /// <param name="mouseInfo">A MouseStruct containing information from which to construct MouseEventExtArgs.</param>
        /// <returns>A new MouseEventExtArgs object.</returns>
        private static MouseEventExtArgs FromRawDataUniversal(IntPtr wParam, MouseStruct mouseInfo)
        {
            MouseButtons button = MouseButtons.None;
            short mouseDelta = 0;
            int clickCount = 0;

            bool isMouseButtonDown = false;
            bool isMouseButtonUp = false;


            switch ((long) wParam)
            {
                case Messages.WM_LBUTTONDOWN:
                    isMouseButtonDown = true;
                    button = MouseButtons.Left;
                    clickCount = 1;
                    break;
                case Messages.WM_LBUTTONUP:
                    isMouseButtonUp = true;
                    button = MouseButtons.Left;
                    clickCount = 1;
                    break;
                case Messages.WM_LBUTTONDBLCLK:
                    isMouseButtonDown = true;
                    button = MouseButtons.Left;
                    clickCount = 2;
                    break;
                case Messages.WM_RBUTTONDOWN:
                    isMouseButtonDown = true;
                    button = MouseButtons.Right;
                    clickCount = 1;
                    break;
                case Messages.WM_RBUTTONUP:
                    isMouseButtonUp = true;
                    button = MouseButtons.Right;
                    clickCount = 1;
                    break;
                case Messages.WM_RBUTTONDBLCLK:
                    isMouseButtonDown = true;
                    button = MouseButtons.Right;
                    clickCount = 2;
                    break;
                case Messages.WM_MBUTTONDOWN:
                    isMouseButtonDown = true;
                    button = MouseButtons.Middle;
                    clickCount = 1;
                    break;
                case Messages.WM_MBUTTONUP:
                    isMouseButtonUp = true;
                    button = MouseButtons.Middle;
                    clickCount = 1;
                    break;
                case Messages.WM_MBUTTONDBLCLK:
                    isMouseButtonDown = true;
                    button = MouseButtons.Middle;
                    clickCount = 2;
                    break;
                case Messages.WM_MOUSEWHEEL:
                    mouseDelta = mouseInfo.MouseData;
                    break;
                case Messages.WM_XBUTTONDOWN:
                    button = mouseInfo.MouseData == 1
                        ? MouseButtons.XButton1
                        : MouseButtons.XButton2;
                    isMouseButtonDown = true;
                    clickCount = 1;
                    break;

                case Messages.WM_XBUTTONUP:
                    button = mouseInfo.MouseData == 1
                        ? MouseButtons.XButton1
                        : MouseButtons.XButton2;
                    isMouseButtonUp = true;
                    clickCount = 1;
                    break;

                case Messages.WM_XBUTTONDBLCLK:
                    isMouseButtonDown = true;
                    button = mouseInfo.MouseData == 1
                        ? MouseButtons.XButton1
                        : MouseButtons.XButton2;
                    clickCount = 2;
                    break;

                case Messages.WM_MOUSEHWHEEL:
                    mouseDelta = mouseInfo.MouseData;
                    break;
            }

            var e = new MouseEventExtArgs(
                button,
                clickCount,
                mouseInfo.Point,
                mouseDelta,
                mouseInfo.Timestamp,
                isMouseButtonDown,
                isMouseButtonUp);

            return e;
        }
예제 #15
0
        /// <summary>
        ///     Suppress mouse keys.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The e.</param>
        private void HookManager_SupressMouse(object sender, MouseEventExtArgs e)
        {
            if (_controller.IsShouldSupressMouse(e.Button))
            {
                Log(string.Format("MouseDown \t\t {0} Suppressed\n", e.Button));
                e.Handled = true;
                return;
            }

            Log(string.Format("MouseDown \t\t {0}\n", e.Button));
        }
예제 #16
0
 /// <summary>
 ///     Hooks the manager_ mouse wheel ext.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The e.</param>
 private void HookManager_MouseWheelExt(object sender, MouseEventExtArgs e)
 {
     if (_controller.IsShouldSupressMouseWheel())
     {
         Log("Mouse Wheel Move Suppressed.\n");
         e.Handled = true;
     }
 }
예제 #17
0
        static void M_events_MouseDownExt(object sender, MouseEventExtArgs e)
        {
            if (e.X <= 50 && e.Y <= 50 && e.Button == System.Windows.Forms.MouseButtons.XButton2)
            {
                e.Handled = true;
                transmitMouse = !transmitMouse;
                if (transmitMouse)
                {
                    Cursor.Hide();
                    Controller.MoveCursor(dstMousePos.X, dstMousePos.Y);
                    srcMousePos = e.Location;
                }
                else
                {
                    Cursor.Show();
                    Controller.MoveCursor(srcMousePos.X, srcMousePos.Y);
                    dstMousePos = e.Location;
                }
                return;
            }

            if (transmitMouse)
            {
                e.Handled = true;
                //if (e.Button.HasFlag(System.Windows.Forms.MouseButtons.Left) && e.Clicked) com.SendClick(MouseButtons.Left);
                //else 
                if (e.Button.HasFlag(System.Windows.Forms.MouseButtons.Left) && e.IsMouseButtonDown) com.SendDown(MouseButtons.Left);
                if (e.Button.HasFlag(System.Windows.Forms.MouseButtons.Left) && (e.IsMouseButtonUp | e.Clicked)) com.SendUp(MouseButtons.Left);

                //if (e.Button.HasFlag(System.Windows.Forms.MouseButtons.Right) && e.Clicked) com.SendClick(MouseButtons.Right);
                //else 
                if (e.Button.HasFlag(System.Windows.Forms.MouseButtons.Right) && e.IsMouseButtonDown) com.SendDown(MouseButtons.Right);
                if (e.Button.HasFlag(System.Windows.Forms.MouseButtons.Right) && (e.IsMouseButtonUp | e.Clicked)) com.SendUp(MouseButtons.Right);

                //if (e.Button.HasFlag(System.Windows.Forms.MouseButtons.Middle) && e.Clicked) com.SendClick(MouseButtons.Middle);
                //else 
                if (e.Button.HasFlag(System.Windows.Forms.MouseButtons.Middle) && e.IsMouseButtonDown) com.SendDown(MouseButtons.Middle);
                if (e.Button.HasFlag(System.Windows.Forms.MouseButtons.Middle) && (e.IsMouseButtonUp | e.Clicked)) com.SendUp(MouseButtons.Middle);

                if (e.Button.HasFlag(System.Windows.Forms.MouseButtons.XButton1) && e.IsMouseButtonDown) com.SendDown(MouseButtons.Back);
                if (e.Button.HasFlag(System.Windows.Forms.MouseButtons.XButton1) && (e.IsMouseButtonUp | e.Clicked)) com.SendUp(MouseButtons.Back);

                if (e.Button.HasFlag(System.Windows.Forms.MouseButtons.XButton2) && e.IsMouseButtonDown) com.SendDown(MouseButtons.Forward);
                if (e.Button.HasFlag(System.Windows.Forms.MouseButtons.XButton2) && (e.IsMouseButtonUp | e.Clicked)) com.SendUp(MouseButtons.Forward);

                int ticks = Math.Abs(e.Delta);


                if (e.Delta < 0)
                {
                    for (int i = e.Delta; i < 0; i += 120)
                    {
                        com.SendClick(MouseButtons.ScrollDown);
                    }
                }
                else if (e.Delta > 0)
                {
                    for (int i = 0; i < e.Delta; i += 120)
                    {
                        com.SendClick(MouseButtons.ScrollUp);
                    }
                }
            }
        }
 private void GlobalHookMouseUpExt(object sender, MouseEventExtArgs e)
 {
     if (e.Button == MouseButtons.Right)
     {
         m_MouseClickTimer.Stop();
     }
 }