首页 > 其他 > 详细

模拟鼠标点击

时间:2014-02-07 17:42:00      阅读:384      评论:0      收藏:0      [点我收藏+]
using System.Runtime.InteropServices; 

#region API

[DllImport("user32.dll")]
static externvoid mouse_event(MouseEventFlag flags, int dx, int dy, uint data, UIntPtr extraInfo);
[Flags]
enum MouseEventFlag : uint
{
Move = 0x0001,
LeftDown = 0x0002,
LeftUp = 0x0004,
RightDown = 0x0008,
RightUp = 0x0010,
MiddleDown = 0x0020,
MiddleUp = 0x0040,
XDown = 0x0080,
XUp = 0x0100,
Wheel = 0x0800,
VirtualDesk = 0x4000,
Absolute = 0x8000
}

#endregion

//以上代码放在Class 任意处

mouse_event(MouseEventFlag.LeftDown, 0, 0, 0, UIntPtr.Zero);
//执行左键按下
mouse_event(MouseEventFlag.LeftUp, 0, 0, 0, UIntPtr.Zero);
//执行左键松开

//完成一个单击动作

//之后执行以上代码便可模似鼠标单击一次

LeftDown事件前,添上:mouse_event(MouseEventFlag.Move, 0, 0, 0, UIntPtr.Zero)

模拟鼠标点击

原文:http://www.cnblogs.com/chengeng/p/3539459.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!