zoukankan      html  css  js  c++  java
  • c#模拟鼠标左键单击

     [System.Runtime.InteropServices.DllImport("user32.dll")]
            private static extern int mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);
            const int MOUSEEVENTF_MOVE = 0x0001;
            const int MOUSEEVENTF_LEFTDOWN = 0x0002;
            const int MOUSEEVENTF_LEFTUP = 0x0004;
            const int MOUSEEVENTF_RIGHTDOWN = 0x0008;
            const int MOUSEEVENTF_RIGHTUP = 0x0010;
            const int MOUSEEVENTF_MIDDLEDOWN = 0x0020;
            const int MOUSEEVENTF_MIDDLEUP = 0x0040;
            const int MOUSEEVENTF_ABSOLUTE = 0x8000;

    以下是调用代码:

    mouse_event(MOUSEEVENTF_MOVE, 200, 0, 0, 0);
    mouse_event(MOUSEEVENTF_LEFTDOWN, 1, 0, 0, 0);
    mouse_event(MOUSEEVENTF_LEFTUP, 1, 0, 0, 0);

    上面代码的移动鼠标会有点问题,这个不是绝对的坐标。以下代码是绝对坐标

    声明:

    [DllImport("User32.dll")]
    private static extern bool SetCursorPos(int x, int y);

    调用:

    SetCursorPos(100, 200);
  • 相关阅读:
    Arduino
    DTU
    现代信号处理与应用
    matlab学习记录
    列车准点节能操纵
    泊松过程
    序号生成算法odoo
    操作系统特性
    c语言中的变量
    xml中的四则运算与时间爱格式
  • 原文地址:https://www.cnblogs.com/codeDevotee/p/7270392.html
Copyright © 2011-2022 走看看