Esempio n. 1
0
        private void HookManager_MouseClick(object sender, MouseEventArgs e)
        {
            if (mouseTracking == 2)
            {
                ClickRecordType clickType = ClickRecordType.NoClick;

                switch (e.Button)
                {
                case MouseButtons.Left:
                    clickType = ClickRecordType.LeftClick;
                    break;

                case MouseButtons.Middle:
                    clickType = ClickRecordType.MiddleClick;
                    break;

                case MouseButtons.Right:
                    clickType = ClickRecordType.RightClick;
                    break;
                }

                if (stopwatch.IsRunning)
                {
                    InternalNode.Settings.Records.Add(new DurationRecord(GUIUtilities.ToInt32(stopwatch.ElapsedMilliseconds)));
                    stopwatch.Restart();
                }

                else
                {
                    stopwatch.Start();
                }

                InternalNode.Settings.Records.Add(new ClickRecord(clickType, Cursor.Position));
            }
        }
Esempio n. 2
0
        public static void SmoothClickMouseTo(Point dest, Int32 totalDuration, ClickRecordType clickType)
        {
            Point start = Cursor.Position;
            PointF iterPoint = start;
            Int32 steps = totalDuration / MouseEventDelayMS;

            // Find the slope of the line segment defined by start and dest
            PointF slope = new PointF(dest.X - start.X, dest.Y - start.Y);

            // Divide by the number of steps
            slope.X = slope.X / steps;
            slope.Y = slope.Y / steps;

            // Move the mouse to each iterative point.
            for(int i = 0; i < steps; i++)
            {
                iterPoint = new PointF(iterPoint.X + slope.X, iterPoint.Y + slope.Y);
                Cursor.Position = Point.Round(iterPoint);
                System.Threading.Thread.Sleep(MouseEventDelayMS + (new Random()).Next(4));
            }

            // Move the mouse to the final destination.
            Cursor.Position = dest;
            DoClickMouse(clickType);
        }
Esempio n. 3
0
        public static void DoClickMouse(ClickRecordType clickType)
        {
            INPUT mouseInput = new INPUT()
            {
                type = 0, // Mouse input
                mi = new MOUSEINPUT()
            };

            switch(clickType)
            {
                case ClickRecordType.LeftClick:
                    mouseInput.mi.dwFlags = MouseEventFlags.LeftDown;
                    SendInput(1, ref mouseInput, Marshal.SizeOf(new INPUT()));
                    System.Threading.Thread.Sleep(150);
                    mouseInput.mi.dwFlags = MouseEventFlags.LeftUp;
                    SendInput(1, ref mouseInput, Marshal.SizeOf(new INPUT()));
                    break;

                case ClickRecordType.RightClick:
                    mouseInput.mi.dwFlags = MouseEventFlags.RightDown;
                    SendInput(1, ref mouseInput, Marshal.SizeOf(new INPUT()));
                    System.Threading.Thread.Sleep(150);
                    mouseInput.mi.dwFlags = MouseEventFlags.RightUp;
                    SendInput(1, ref mouseInput, Marshal.SizeOf(new INPUT()));
                    break;

                case ClickRecordType.MiddleClick:
                    mouseInput.mi.dwFlags = MouseEventFlags.MiddleDown;
                    SendInput(1, ref mouseInput, Marshal.SizeOf(new INPUT()));
                    System.Threading.Thread.Sleep(150);
                    mouseInput.mi.dwFlags = MouseEventFlags.MiddleUp;
                    SendInput(1, ref mouseInput, Marshal.SizeOf(new INPUT()));
                    break;
            }
        }
Esempio n. 4
0
        public static void DoClickMouse(ClickRecordType clickType)
        {
            INPUT mouseInput = new INPUT()
            {
                type = 0, // Mouse input
                mi   = new MOUSEINPUT()
            };

            switch (clickType)
            {
            case ClickRecordType.LeftClick:
                mouseInput.mi.dwFlags = MouseEventFlags.LeftDown;
                SendInput(1, ref mouseInput, Marshal.SizeOf(new INPUT()));
                System.Threading.Thread.Sleep(150);
                mouseInput.mi.dwFlags = MouseEventFlags.LeftUp;
                SendInput(1, ref mouseInput, Marshal.SizeOf(new INPUT()));
                break;

            case ClickRecordType.RightClick:
                mouseInput.mi.dwFlags = MouseEventFlags.RightDown;
                SendInput(1, ref mouseInput, Marshal.SizeOf(new INPUT()));
                System.Threading.Thread.Sleep(150);
                mouseInput.mi.dwFlags = MouseEventFlags.RightUp;
                SendInput(1, ref mouseInput, Marshal.SizeOf(new INPUT()));
                break;

            case ClickRecordType.MiddleClick:
                mouseInput.mi.dwFlags = MouseEventFlags.MiddleDown;
                SendInput(1, ref mouseInput, Marshal.SizeOf(new INPUT()));
                System.Threading.Thread.Sleep(150);
                mouseInput.mi.dwFlags = MouseEventFlags.MiddleUp;
                SendInput(1, ref mouseInput, Marshal.SizeOf(new INPUT()));
                break;
            }
        }
Esempio n. 5
0
        public static void SmoothClickMouseTo(Point dest, Int32 totalDuration, ClickRecordType clickType)
        {
            Point  start     = Cursor.Position;
            PointF iterPoint = start;
            Int32  steps     = totalDuration / MouseEventDelayMS;

            // Find the slope of the line segment defined by start and dest
            PointF slope = new PointF(dest.X - start.X, dest.Y - start.Y);

            // Divide by the number of steps
            slope.X = slope.X / steps;
            slope.Y = slope.Y / steps;

            // Move the mouse to each iterative point.
            for (int i = 0; i < steps; i++)
            {
                iterPoint       = new PointF(iterPoint.X + slope.X, iterPoint.Y + slope.Y);
                Cursor.Position = Point.Round(iterPoint);
                System.Threading.Thread.Sleep(MouseEventDelayMS + (new Random()).Next(4));
            }

            // Move the mouse to the final destination.
            Cursor.Position = dest;
            DoClickMouse(clickType);
        }
Esempio n. 6
0
 public ClickRecord(ClickRecordType clickType, Point point)
     : base(RecordType.ClickRecord)
 {
     _subType    = clickType;
     TargetPoint = point;
 }
Esempio n. 7
0
 public ClickRecord(ClickRecordType clickType, Point point)
     : base(RecordType.ClickRecord)
 {
     _subType = clickType;
     TargetPoint = point;
 }