title: Programmatically press a button on another application (C, Windows)
body: <p>I'm trying to use the following code to press a button on my other application:</p>
  
  <pre><code>HWND ButtonHandle;
  if( (wnd = FindWindow(0, "Do you want to save?")) )
  {   
     ButtonHandle = FindWindowEx(wnd, 0, "SaveButton", "&amp;Save");
     SendMessage(wnd, WM_COMMAND, MAKEWORD(GetDlgCtrlID(ButtonHandle), BN_CLICKED ), (LPARAM)ButtonHandle);
  
  }
  </code></pre>
  
  <p>It doesn't work. I tried passing different handles to MAKEWORD and to change the WPARM and LPARAM but nothing.</p>
  
  <p>Any ideas on how to click a button on another application's window?</p>
  
  <p>Code is appreciated.
  Thanks.</p>
  
  <p>EDIT:
  The reason it doesn't seem to work permissions. I sent a PostMessage() and the result was an error with GetLastError() = 5 (or Access Denied).
  Any ideas?</p>
  
  <p><strong>EDIT2</strong> I don't mean to be rude but please please please, I already searched all the API's including getting and setting the regions for the button and then sending a button down and button up, getting the control ID, getting the class ID and a zillion more.
  The reason I asked the question here in the first place is because I already exhausted my search on the internet.
  If you know the answer <strong>PLEASE POST CODE</strong>, do not suggest an API and that's it, show me how does that API solves the problem. It's not hard.
  thank you. </p>
  
  <p><strong>EDIT 3: The question's answer was selected automatically when the bounty finished. The question still remains without an answer.</strong></p>