注释感觉已经很清楚了,有不懂的欢迎评论 1 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Threading; using Syst
想必有很多人在项目开发中可能遇见需要做模拟鼠标点击的小功能,很多人会在 百度过后采用mouse_event这个函数,不过我并不想讨论如何去使用mouse_event 函数怎么去使用,因为那没有多大意义. static void mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo) { int x = dx, y = dy; edit_position(dwFlags, dx, dy, ref x, ref
我们需要用到的mouse_event函数,位于user32.dll这个库文件里面,所以我们要先声明引用. [System.Runtime.InteropServices.DllImport("user32")] private static extern int mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo); //移动鼠标 const int MOUSEEVENTF_MOVE = 0x00
我们需要用到的mouse_event函数,位于user32.dll这个库文件里面,所以我们要先声明引用. [System.Runtime.InteropServices.DllImport("user32")] private static extern int mouse_event(int dwFlags, int dx, int dy, int dwData, int dwExtraInfo); //移动鼠标 const int MOUSEEVENTF_MOVE = 0x0001
思路: 使用Windows API函数遍历窗口,查找指定标题的窗口,然后从该窗口查找确定按钮,向该按钮发送鼠标消息进行模拟点击.由于IE8由Alert弹出的网页对话框的标题是“来自网页的消息”,而IE6由Alert弹出的网页对话框的标题是“Microsoft Internet Explorer”,所以本文没有按查找窗口标题方法获取窗口句柄.注意到不管IE哪个版本,IE窗口的类名都是“IEFrame”,而网页对话框的父窗口是IE窗口,所以本文是根据父窗口的类名是不是IEFrame来判断窗口是不是网