Exemple #1
0
        public static void mouseClick()
        {
            var point = MouseOperations.GetCursorPosition();
            int x     = point.X;
            int y     = point.Y;

            MouseOperations.mouse_event((int)(MouseOperations.MouseEventFlags.Absolute | MouseOperations.MouseEventFlags.LeftDown), x, y, 0, 0);
            int sleep = getRandom(60, 150);

            Thread.Sleep(sleep);
            MouseOperations.mouse_event((int)(MouseOperations.MouseEventFlags.Absolute | MouseOperations.MouseEventFlags.LeftUp), x, y, 0, 0);
        }
Exemple #2
0
        public static void LinearSmoothMove(Point newPosition, TimeSpan duration)
        {
            var   point = MouseOperations.GetCursorPosition();
            Point start = new Point(point.X, point.Y);

            // Find the vector between start and newPosition
            double deltaX = newPosition.X - start.X;
            double deltaY = newPosition.Y - start.Y;

            // start a timer
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            double timeFraction = 0.0;

            do
            {
                timeFraction = (double)stopwatch.Elapsed.Ticks / duration.Ticks;
                if (timeFraction > 1.0)
                {
                    timeFraction = 1.0;
                }

                PointF curPoint = new PointF(Convert.ToInt32(start.X + timeFraction * deltaX),
                                             Convert.ToInt32(start.Y + timeFraction * deltaY));

                //MouseOperations.SetCursorPos(Convert.ToInt32(curPoint.X), Convert.ToInt32(curPoint.Y));
                //MouseSimulator.MouseMove(Convert.ToInt32(curPoint.X), Convert.ToInt32(curPoint.Y));
                int inputXinPixels = Convert.ToInt32(curPoint.X);
                int inputYinPixels = Convert.ToInt32(curPoint.Y);
                var screenBounds   = Screen.PrimaryScreen.Bounds;
                var outputX        = inputXinPixels * 65535 / screenBounds.Width;
                var outputY        = inputYinPixels * 65535 / screenBounds.Height;
                //Console.WriteLine(outputX);
                MouseSimulator.MouseMove(outputX, outputY);
                Thread.Sleep(50);
            } while (timeFraction < 1.0);
        }
Exemple #3
0
 public static void mouseMove(int x, int y)
 {
     MouseOperations.mouse_event((int)(MouseOperations.MouseEventFlags.Absolute | MouseOperations.MouseEventFlags.Move), x, y, 0, (int)UIntPtr.Zero);
 }