C#的鼠标控制代码
// using System.Runtime.InteropServices;
[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
}
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
}
[DllImport("user32.dll")]
static extern void mouse_event(MouseEventFlag flags, int dx, int dy, uint data, UIntPtr extraInfo);
static extern void mouse_event(MouseEventFlag flags, int dx, int dy, uint data, UIntPtr extraInfo);
// only mouse move
[DllImport("user32.dll")]
static extern bool SetCursorPos(int X, int Y);
[DllImport("user32.dll")]
static extern bool SetCursorPos(int X, int Y);
// Get Cursor Positon
[System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "GetCursorPos")]
public extern static int GetCursorPos(ref POINTAPI lpPoint);
[System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "GetCursorPos")]
public extern static int GetCursorPos(ref POINTAPI lpPoint);
本文转自Jack Niu博客园博客,原文链接:http://www.cnblogs.com/skywind/archive/2007/03/03/663107.html,如需转载请自行联系原作者