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(0, 0);
    MoveMouseToPoint(centerP);
    }

  • 相关阅读:
    UVA10361
    △UVA10494
    △UVA465
    △UVA10106
    △UVA424
    阶乘的精确值
    小学生算术
    UVA156
    △UVA120
    linux应用之ntpdate命令联网同步时间
  • 原文地址:https://www.cnblogs.com/wanglg/p/6563397.html
Copyright © 2011-2022 走看看