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);
    }

  • 相关阅读:
    矩阵图
    博客园评价
    团队冲刺
    团队冲刺
    第二阶段团队冲刺
    团队博客
    团队冲刺
    总结会议
    会议10
    会议09
  • 原文地址:https://www.cnblogs.com/wanglg/p/6563397.html
Copyright © 2011-2022 走看看