zoukankan      html  css  js  c++  java
  • C#调用API:mouse_event 模拟鼠标事件

    using System.Runtime.InteropServices; 

    [DllImport("user32", EntryPoint = "mouse_event")

      private static extern int mouse_event(
        int dwFlags,// 下表中标志之一或它们的组合
        int dx,
        int dy, //指定x,y方向的绝对位置或相对位置
        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_LEFTDOWN, 500, 400, 0, 0);

        mouse_event(MOUSEEVENTF_LEFTUP, 500, 400, 0, 0);

  • 相关阅读:
    Automated Telephone Exchange
    Babelfish
    又见回文
    487-3279
    Robot Motion
    99. Recover Binary Search Tree
    98. Validate Binary Search Tree
    97. Interleaving String
    96. Unique Binary Search Trees
    95. Unique Binary Search Trees II
  • 原文地址:https://www.cnblogs.com/icebutterfly/p/2128353.html
Copyright © 2011-2022 走看看