Try using SetCursorPos and mouse_event.
Code:
#include <windows.h>
int main(void)
{
int i;
for (i = 0; i < 30000; i++)
{
/* Move cursor to screen position 10, 10 */
SetCursorPos(10, 10);
/* Right mouse click. */
mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0);
mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0);
/* Move cursor to screen position 20, 20 */
SetCursorPos(20, 20);
/* Left mouse click. */
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
/* Pause so mouse clicks are not interpreted as a double click. */
Sleep( GetDoubleClickTime() + 100 );
/* Left mouse click. */
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
/* Pause for action to be processed. */
Sleep(500);
}
return 0;
}