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

      

  • 相关阅读:
    javascript中获取dom元素高度和宽度
    $.ajax()方法详解
    JQ中$(window).load和$(document).ready区别与执行顺序
    第几个幸运数
    乘积尾零
    星期一
    分数
    卡片换位
    冰雹数
    打印方格
  • 原文地址:https://www.cnblogs.com/feiyucha/p/10289580.html
Copyright © 2011-2022 走看看