c# winform 控制鼠标,让鼠标在窗体的指定坐标上单击

我希望单击一个按钮后,鼠标能自动移动到程序界面的指定坐标处单击一下。这个如何实现,请高手帮忙
在你的窗体代码中添加如下API定义代码(引人System.Runtime.InteropServices命名空间(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
}
[DllImport("user32.dll")]
static extern void mouse_event(MouseEventFlag flags, int dx, int dy, uint data, UIntPtr extraInfo);

在你的磨历穗按钮单击事件中(Button_Click)加入如下代码:

Cursor.Position = new Point(0 /*x坐烂友标*/, 0 /*y坐标*/); //这里是移动鼠标的代码
mouse_event(MouseEventFlag.LeftDown,0,0,0,UIntPtr.Zero);
mouse_event(MouseEventFlag.LeftUp,0,0,0,UIntPtr.Zero);
//这里是鼠标点击的代码(瞎卜左键)