Пример #1
0
        public void Execute(IScreenParser parser)
        {
            POINT targetPoint = new POINT(parser.GetXCoord(Target.X) + 25, parser.GetYCoord(Target.Y) + 25);

            User32Api.SetCursorPos(targetPoint.X, targetPoint.Y);

            switch (Move)
            {
            case MoveTypes.DoubleClick:
                User32Api.MouseDoubleClick(targetPoint);
                break;

            case MoveTypes.SetFlag:
                if (Target.State == BlockState.Flag)
                {
                    return;
                }
                else if (Target.UserGuess)
                {
                    User32Api.MouseRightClick(targetPoint);
                }
                User32Api.MouseRightClick(targetPoint);
                break;

            case MoveTypes.SetClear:
                User32Api.MouseClick(targetPoint);
                break;
            }
        }
Пример #2
0
        protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e) //使用冒泡事件
        {
            if (_direction != Direction.NONE)
            {
                var pos     = this.PointToScreen(Mouse.GetPosition(this));   //鼠标屏幕坐标
                var leftTop = this.PointToScreen(new Point(0, 0));           //左上
                var right   = this.PointToScreen(new Point(this.Width, 0));  //右
                var bottom  = this.PointToScreen(new Point(0, this.Height)); //下

                if (pos.X - leftTop.X <= 2)                                  //左
                {
                    User32Api.SetCursorPos((int)pos.X + 1, (int)pos.Y);
                }
                else if (pos.Y - leftTop.Y <= 2) //上
                {
                    User32Api.SetCursorPos((int)pos.X, (int)pos.Y + 1);
                }
                else if (right.X - pos.X <= 2) //右
                {
                    User32Api.SetCursorPos((int)pos.X - 1, (int)pos.Y);
                }
                else if (bottom.Y - pos.Y <= 2) //下
                {
                    User32Api.SetCursorPos((int)pos.X, (int)pos.Y - 1);
                }
            }
            else if (e.ClickCount == 2 && Mouse.GetPosition(this).Y <= this._headHeight) //双击最大化
            {
                if (this.WindowState == WindowState.Normal)
                {
                    this.WindowState = WindowState.Maximized;
                }
                else
                {
                    this.WindowState = WindowState.Normal;
                }
                e.Handled = true;
            }
            base.OnMouseLeftButtonDown(e);
        }
Пример #3
0
        /// <summary>
        /// 找到指定指针样式的伪控件(绘画上去的,不支持某些操作)(不完善)
        /// </summary>
        /// <param name="rectangle">查找的范围</param>
        /// <param name="bCursor">背景光标</param>
        /// <param name="direction">1右,2下,3左,4上</param>
        /// <returns></returns>
        public static Point FindCursorStyleChange(RECT rectangle, int direction, params int[] excludes)
        {
            int span = 10;
            int cursor;

            User32Api.SetCursorPos(rectangle.left, rectangle.top);
            cursor = GetCursorStyle();
            List <int> excludelist = new List <int>(excludes);

            excludelist.Add(cursor);
            switch (direction)
            {
            case 1:
                for (int x = rectangle.left + span; x < rectangle.right; x = x + span)
                {
                    for (int y = rectangle.top + span; y < rectangle.bottom; y = y + span)
                    {
                        User32Api.SetCursorPos(x, y);
                        int c = GetCursorStyle();
                        Console.WriteLine(c);
                        if (!excludelist.Contains(c))
                        {
                            return(new Point(x, y));
                        }
                    }
                }
                break;

            case 2:
                for (int y = rectangle.top + span; y < rectangle.bottom; y = y + span)
                {
                    for (int x = rectangle.left + span; x < rectangle.right; x = x + span)
                    {
                        User32Api.SetCursorPos(x, y);
                        int c = GetCursorStyle();
                        Console.WriteLine(c);
                        if (!excludelist.Contains(c))
                        {
                            return(new Point(x, y));
                        }
                    }
                }
                break;

            case 3:
                for (int x = rectangle.right - span; x > rectangle.left; x = x - span)
                {
                    for (int y = rectangle.top + span; y < rectangle.bottom; y = y + span)
                    {
                        User32Api.SetCursorPos(x, y);
                        int c = GetCursorStyle();
                        Console.WriteLine(c);
                        if (!excludelist.Contains(c))
                        {
                            return(new Point(x, y));
                        }
                    }
                }
                break;

            case 4:
                for (int y = rectangle.bottom - span; y > rectangle.top; y = y - span)
                {
                    for (int x = rectangle.left + span; x < rectangle.right; x = x + span)
                    {
                        User32Api.SetCursorPos(x, y);
                        int c = GetCursorStyle();
                        Console.WriteLine(c);
                        if (!excludelist.Contains(c))
                        {
                            return(new Point(x, y));
                        }
                    }
                }
                break;
            }
            return(Point.Empty);
        }
Пример #4
0
        /// <summary>
        /// 找到指定指针样式的伪控件(绘画上去的,不支持某些操作)
        /// </summary>
        /// <param name="windowModel">以该控件为基点</param>
        /// <param name="direction">1右,2下,3左,4上</param>
        /// <returns></returns>
        public static Point FindCursorStyle(WindowModel windowModel, int hCursor, int direction)
        {
            int bottom = 0;
            int right  = 0;
            int span   = 10;

            switch (direction)
            {
            case 1:
                bottom = windowModel.WindowRectangle.Bottom;
                right  = windowModel.Parent.WindowRectangle.Right;
                for (int x = windowModel.WindowRectangle.Right + span; x < right; x = x + span)
                {
                    for (int y = windowModel.WindowRectangle.Top + span; y < bottom; y = y + span)
                    {
                        User32Api.SetCursorPos(x, y);
                        int c = GetCursorStyle();
                        Console.WriteLine(c);
                        if (c == hCursor)
                        {
                            return(new Point(x, y));
                        }
                    }
                }
                break;

            case 2:
                bottom = windowModel.Parent.WindowRectangle.Bottom;
                right  = windowModel.WindowRectangle.Right;
                for (int y = windowModel.WindowRectangle.Bottom + span; y < bottom; y = y + span)
                {
                    for (int x = windowModel.WindowRectangle.Left + span; x < right; x = x + span)
                    {
                        User32Api.SetCursorPos(x, y);
                        int c = GetCursorStyle();
                        Console.WriteLine(c);
                        if (c == hCursor)
                        {
                            return(new Point(x, y));
                        }
                    }
                }
                break;

            case 3:
                bottom = windowModel.WindowRectangle.Bottom;
                int left = windowModel.Parent.WindowRectangle.Left;
                for (int x = windowModel.WindowRectangle.Left - span; x > left; x = x - span)
                {
                    for (int y = windowModel.WindowRectangle.Top + span; y < bottom; y = y + span)
                    {
                        User32Api.SetCursorPos(x, y);
                        int c = GetCursorStyle();
                        Console.WriteLine(c);
                        if (c == hCursor)
                        {
                            return(new Point(x, y));
                        }
                    }
                }
                break;

            case 4:
                var top = windowModel.Parent.WindowRectangle.Top;
                right = windowModel.WindowRectangle.Right;
                for (int y = windowModel.WindowRectangle.Top - span; y > top; y = y - span)
                {
                    for (int x = windowModel.WindowRectangle.Left + span; x < right; x = x + span)
                    {
                        User32Api.SetCursorPos(x, y);
                        int c = GetCursorStyle();
                        Console.WriteLine(c);
                        if (c == hCursor)
                        {
                            return(new Point(x, y));
                        }
                    }
                }
                break;
            }
            return(Point.Empty);
        }
Пример #5
0
 /// <summary>
 /// 设置鼠标位置
 /// </summary>
 /// <param name="x"></param>
 /// <param name="y"></param>
 public static void SetCursorPos(int x, int y)
 {
     User32Api.SetCursorPos(x, y);
 }
Пример #6
0
        public void MoveMouseToBlock(IScreenParser parser)
        {
            POINT targetPoint = new POINT(parser.GetXCoord(Target.X) + 25, parser.GetYCoord(Target.Y) + 25);

            User32Api.SetCursorPos(targetPoint.X, targetPoint.Y);
        }