This code will click a command button in another program using standard Windows API calls. This example clicks the "Open" button that appears in Internet Explorer when you try to open and executable, script, batch file, etc.
Code:
#include <windows.h>

int main()
{

//create two structures to hold our Main Window handle
//and the Button's handle
HWND WindowHandle;
HWND ButtonHandle;
	
//this window's caption is "File Download", so we search for it's handle using the FindWindow API		
WindowHandle = FindWindow(NULL, "File Download");

//the Button's Caption is "Open" and it is a "Button".  SPYXX.exe that comes with Microsoft Visual Studio will reveal this information to you
ButtonHandle = FindWindowEx(WindowHandle, 0, "Button", "&Open");

//send a message to the button that you are "clicking" it.  Surprisingly C++ understands what BM_CLICK is without having to set it.  Different than VB
SendMessage (ButtonHandle, BM_CLICK, 0 , 0);

return 0;
}