This one should do the job:
public static void ClickSomePoint() {
System.Windows.Forms.Cursor.Position = new Point(20, 35);
DoClickMouse(0x2);
DoClickMouse(0x4);
}
static void DoClickMouse(int mouseButton) {
var input = new INPUT() {
dwType = 0,
mi = new MOUSEINPUT() { dwFlags = mouseButton }
};
if (SendInput(1, input, Marshal.SizeOf(input)) == 0) {
throw new Exception();
}
}
[StructLayout(LayoutKind.Sequential)]
struct MOUSEINPUT {
int dx;
int dy;
int mouseData;
public int dwFlags;
int time;
IntPtr dwExtraInfo;
}
struct INPUT {
public uint dwType;
public MOUSEINPUT mi;
}
[DllImport("user32.dll", SetLastError=true)]
static extern uint SendInput(uint cInputs, INPUT input, int size);
Source:
stackoverflow.com[
^]