zoukankan      html  css  js  c++  java
  • C# 操作鼠标移动到指定的屏幕位置方法

     /// <summary>
            /// 引用user32.dll动态链接库(windows api),
            /// 使用库中定义 API:SetCursorPos 
            /// </summary>
            [DllImport("user32.dll")]
            private static extern int SetCursorPos(int x, int y);
            /// <summary>
            /// 移动鼠标到指定的坐标点
            /// </summary>
            public void MoveMouseToPoint(Point p)
            {
                SetCursorPos(p.X, p.Y);
            }
            /// <summary>
            /// 设置鼠标的移动范围
            /// </summary>
            public void SetMouseRectangle(Rectangle rectangle)
            {
                System.Windows.Forms.Cursor.Clip = rectangle;
            }
            /// <summary>
            /// 设置鼠标位于屏幕中心
            /// </summary>
            public void SetMouseAtCenterScreen()
            {
                int winHeight = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height;
                int winWidth = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width;
                Point centerP = new Point(winWidth / 2, winHeight / 2);
                MoveMouseToPoint(centerP);
            }
  • 相关阅读:
    多态
    封装
    继承
    面向对象
    2.机器学习相关数学基础
    作业1 机器学习概述
    作业15 语法制导的语义翻译
    作业14 算符优先分析
    作业13 自下而上语法分析
    作业12 实验二 递归下降语法分析
  • 原文地址:https://www.cnblogs.com/niuww/p/3155948.html
Copyright © 2011-2022 走看看