C#模拟鼠标点击
请问有没有什么方法可以模拟鼠标点击,而且不影响鼠标使用,比如说我用鼠标在玩游戏,并且后台C#程序在模拟鼠标在后台点击其他内容(注:和我用鼠标玩游戏不一样,就好像有两个鼠标...
请问有没有什么方法可以模拟鼠标点击,而且不影响鼠标使用,比如说我用鼠标在玩游戏,并且后台C#程序在模拟鼠标在后台点击其他内容(注:和我用鼠标玩游戏不一样,就好像有两个鼠标在同时运行),请问有什么方法?或者思路也行..
展开
2个回答
展开全部
using System.Runtime.InteropServices;
[DllImport("user32.dll")]
static extern void 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
}
mouse_event(MouseEventFlag.Move, 0, 0, 0, UIntPtr.Zero)
mouse_event(MouseEventFlag.LeftDown, 0, 0, 0, UIntPtr.Zero);
mouse_event(MouseEventFlag.LeftUp, 0, 0, 0, UIntPtr.Zero);
[DllImport("user32.dll")]
static extern void 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
}
mouse_event(MouseEventFlag.Move, 0, 0, 0, UIntPtr.Zero)
mouse_event(MouseEventFlag.LeftDown, 0, 0, 0, UIntPtr.Zero);
mouse_event(MouseEventFlag.LeftUp, 0, 0, 0, UIntPtr.Zero);
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询