Something along the lines of: (pseudo code)
Code:
void leftMouseClick(HWND window, int x, int y) // note: x, y are relative to the screen, not the client., so if the client is located at 500,500 and you want to click at 5, 5 - x, y would be: 505, 505.
{
SendMessage(window, WM_MBUTTONDOWN, MK_LBUTTON, MAKELPARAM(x, y));
SendMessage(window, WM_MBUTTONUP, MK_LBUTTON, MAKELPARAM(x, y));
}
Then you need some way of making scripts to do the clicking for you. (it might be alot more in depth than you think).