ColinOL

A Small Website

用户工具

站点工具


wiki:csharp:base-mnsbdj

模拟鼠标点击

[System.Runtime.InteropServices.DllImport("user32")]
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
}
 
private void btnTestMoustClick_Click(object sender, EventArgs e)
{
   mouse_event(MouseEventFlag.LeftDown | MouseEventFlag.LeftUp, 20, 20, 0, UIntPtr.Zero);
}
wiki/csharp/base-mnsbdj.txt · 最后更改: 2018/02/03 20:42 (外部编辑)