zoukankan      html  css  js  c++  java
  • 模拟鼠标操作

    实现效果:

      

    知识运用:
      API函数mouse_event    //模拟鼠标的事件

    [DllImport("user32.dll", CallingConvention = CallingConvention.StdCall)]
    public extern static IntPtr mouse_event(Int32 dwFlag,Int32 dx,Int32 dy,Int32 dwData,Int32 dwExtraInfo);

    实现代码:

            [DllImport("user32.dll", CallingConvention = CallingConvention.StdCall)]
            public extern static IntPtr mouse_event(Int32 dwFlag,Int32 dx,Int32 dy,Int32 dwData,Int32 dwExtraInfo);
            public const int MOOSEEVENTF_MOVE = 0x0001;             //表示鼠标移动
            public const int MOOSEEVENTF_LEFTDOWN = 0x0002;         //表示鼠标左键按下
            public const int MOOSEEVENTF_LEFTUP = 0x0004;           //表示鼠标左键松开
            private void button1_Click(object sender, EventArgs e)
            {
                mouse_event(MOOSEEVENTF_MOVE,-20,-20,0,0);
                mouse_event(MOOSEEVENTF_LEFTDOWN,0,0,0,0);
                mouse_event(MOOSEEVENTF_LEFTUP,0,0,0,0);
                mouse_event(MOOSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
                mouse_event(MOOSEEVENTF_LEFTUP, 0, 0, 0, 0);
            }
    

      

  • 相关阅读:
    使用 ES2015 编写 Gulp 构建
    ES6 Promise 接口
    Git 文件比较
    JavaScript 属性描述符
    Vim 插件之 NERDTree
    Raspberry Pi 3 Model B 安装 OSMC
    How ADB works
    [Linux] zip 与 unzip 命令
    在 Ubuntu 配置 PPTP Server
    [Linux] 查看系统启动时间
  • 原文地址:https://www.cnblogs.com/feiyucha/p/10289580.html
Copyright © 2011-2022 走看看