Пример #1
0
        public static void MouseMoveEmulationAndUp(int xTarget, int yTarget)
        {
            int xCurrent = Cursor.Position.X;
            int yCurrent = Cursor.Position.Y;

            Console.WriteLine($"Mouse Move and Up on X axis: {xTarget}, and on Y axix {yTarget}");

            int yIncrement = (yCurrent < yTarget) ? 1 : (-1);
            int xIncrement = (xCurrent < xTarget) ? 1 : (-1);

            while (yCurrent != yTarget && xCurrent != xTarget)
            {
                Thread.Sleep(10);
                yCurrent += yIncrement;
                xCurrent += xIncrement;
                MouseEmulate.Move(xCurrent, yCurrent);
            }

            //while (xCurrent != xTarget)
            //{
            //    Thread.Sleep(10);

            //    MouseEmulate.Move(xCurrent, yTarget);
            //};

            Thread.Sleep(1000);
            MouseEmulate.MouseUp(MouseButton.Left);
        }
Пример #2
0
        private static void MouseOver(AutomationElement element, int x_offset, int y_offset)
        {
            var rect   = element.Current.BoundingRectangle;
            int xpoint = (int)(rect.X + x_offset);
            int ypoint = (int)(rect.Y + y_offset);

            Console.WriteLine($"Clicking on X axis: {xpoint}, and on Y axix {ypoint}");
            MouseEmulate.Move(xpoint, ypoint);
            Thread.Sleep(500);
        }