日期:2014-05-17 浏览次数:20956 次
#region 鼠标API
/// <summary>
/// 鼠标移动
/// </summary>
/// <param name="X">目标x坐标</param>
/// <param name="Y">目标y坐标</param>
/// <returns></returns>
[DllImport("user32.dll")]
public static extern bool SetCursorPos(int X, int Y);
[DllImport("user32.dll")]
private static extern int mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);
const int MMove = 0x0001; //移动鼠标
const int LeftDown = 0x0002; //模拟鼠标左键按下
const int LeftUp = 0x0004; //模拟鼠标左键抬起
const int RightDown = 0x0008;// 模拟鼠标右键按下
const int RightUp = 0x0010;// 模拟鼠标右键抬起
const int MiddleDown = 0x0020;// 模拟鼠标中键按下
const int MiddleUp = 0x0040;// 模拟鼠标中键抬起
const int XDown = 0x0080;
const int XUp = 0x0100;
const int Wheel = 0x0800;
const int VirtualDesk = 0x4000;
const int Absolute = 0x8000;// 标示是否采用绝对坐标
/// <summary>
/// 鼠标左键点击
/// </summary>
private void ClickMouse()
{
mouse_event(LeftDown, 0, 0, 0, 0);
Thread.Sleep(200);
mouse_event(LeftUp, 0, 0, 0, 0);
}