예제 #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);
        }
예제 #3
0
        private static void MouseMoveEmulationAndUp(AutomationElement element, int x_offset, int y_offset)
        {
            MouseOver(element);
            var centerPoint = element.GetCenterPoint();
            int xpoint      = Convert.ToInt32(centerPoint.X + x_offset);
            int ypoint      = Convert.ToInt32(centerPoint.Y + y_offset);

            MouseEmulate.MouseDown(MouseButton.Left);
            CommonHelper.MouseMoveEmulationAndUp(xpoint, ypoint);
        }