У меня есть этот код:
[DllImport("user32.dll")]
static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint dwData, UIntPtr dwExtraInfo);
[Flags]
public enum MouseEventFlags
{
Move = 0x0001,
LeftDown = 0x0002,
LeftUp = 0x0004,
RightDown = 0x0008,
RightUp = 0x0010,
MiddleDown = 0x0020,
MiddleUp = 0x0040,
Absolute = 0x8000
}
public void SimMouseEvent(MouseEventFlags e, int x, int y)
{
mouse_event((uint)e, (uint)x, (uint)y, 0, UIntPtr.Zero);
}
public void SimLeftClick(int x, int y)
{
SimMouseEvent(MouseEventFlags.LeftUp | MouseEventFlags.RightUp, x, y);
}
Моя форма выглядит так: