title: VBA hangs when other application opens a Dialog box
body: <p>I use SendMessage API function to click a button in a user form in another application which opens a dialog box. The vba stops at SendMessage and wont execute further until that dialog box is closed.I want the vba to run as it has to fill up a text box in the newly opened dialog box. Any help is appreciated.</p>
  <pre><code>sub api_click_button()
  a = FindWindow(vbNullString, &quot;Exenta Solution&quot;)
  b = FindWindowEx(a, 0&amp;, &quot;WindowsForms10.MDICLIENT.app.0.141b42a_r6_ad1&quot;, vbNullString)
  c = FindWindowEx(b, 0&amp;, &quot;WindowsForms10.Window.8.app.0.141b42a_r6_ad1&quot;, &quot;Inventory&quot;)
  d = FindWindowEx(c, 0&amp;, &quot;WindowsForms10.BUTTON.app.0.141b42a_r6_ad1&quot;, vbNullString)
  Dim xcoord As Long, ycoord As Long, opn_file As Long, winrect As RECT, retval As Long
  
  retval = GetWindowRect(d, winrect)
  xcoord = (winrect.Right - winrect.Left) / 2
  ycoord = (winrect.Bottom - winrect.Top) / 2
  opn = (ycoord * &amp;H10000) + xcoord
  retval = SendMessage(d, WM_LBUTTONDOWN, ByVal CLng(MK_LBUTTON), ByVal opn) ===&gt;stops here 
  retval = SendMessage(d, WM_LBUTTONUP, ByVal CLng(MK_LBUTTON), ByVal opn)
  
  End Sub
  </code></pre>