Use the SendInput() function:
INPUT Inputs[3] = {0};
Inputs[0].type = INPUT_MOUSE;
Inputs[0].mi.dx = ...; // desired X coordinate
Inputs[0].mi.dy = ...; // desired Y coordinate
Inputs[0].mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE;
Inputs[1].type = INPUT_MOUSE;
Inputs[1].mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
Inputs[2].type = INPUT_MOUSE;
Inputs[2].mi.dwFlags = MOUSEEVENTF_LEFTUP;
SendInput(3, Inputs, sizeof(INPUT));
Be sure to read the comments in the MOUSEINPUT documentation regarding how to specify dx
and dy
correctly when using MOUSEEVENTF_ABSOLUTE
in a multi-monitor environment.