title: WM_SETTEXT & WM_GETTEXT delay/lag issue
body: <p>I have tried automating a few external window's Combo box controls using the API functions, SendMessage and PostMessage and using the Window Messages WM_SETTEXT WM_GETTEXTLENGTH and WM_GETTEXT.</p>
  
  <p>I can get this to work when I run through the code for example pressing F11 through each line or putting a breakpoint in and running it at a certain point, but when I run it as normal, the WM_SETTEXT message doesn't update the Combo box.</p>
  
  <p>It seems to be an issue with the speed that the code is running so my first solution was to put a piece of validation that ensures the text is in the combo box, but for some reason the WM_GETTEXT retrieves the text that should be in the text box even though its not visible.</p>
  
  <p>The code below is a snippet of the kind of validation I've tried, my question here would be is there any sort of wait until method I could use to ensure that the text actually gets entered, I know about the Sleep API but I would ideally like something that actually makes sure that text is there and doesn't load f x seconds and hopes that the text is there.</p>
  
  <p>Any ideas are appriciated.</p>
  
  <p>Many Thanks</p>
  
  <p>VB.net Code Example:</p>
  
  <pre><code>Private Enum WindowMessages
      WM_SETTEXT = &amp;HC
      WM_GETTEXT = &amp;HD
      WM_GETTEXTLENGTH = &amp;HE
  End Enum
  
  Private Declare Function SendMessage Lib "user32" Alias _
  "SendMessageA" (ByVal hWnd As Int32, ByVal wMsg As Int32, ByVal _
  wParam As Int32, lParam As String) As Int32
  
  Public Declare Function PostMessage Lib "user32.dll" Alias "PostMessageA" (ByVal hWnd
  As Int32, _
  ByVal wMsg As Int32, ByVal wParam As Int32, ByVal lParam As String) As Int32
  
  Private Sub TestExample(ByVal hWndTextBox as Int32, ByVal TextString as String)
  '####Using the hWnd of a Combo box control and a string to enter in the combo box.####    
  
      Dim TextLength as Int32
      Dim ItemText as string
  
      Do until ItemText = TextString
          SendMessage(hWndTextBox, WM_SETTEXT, 0, TextString) &gt; 0
          TextLength = SendMessage(hWndTextBox, WM_GETTEXTLENGTH, 0, 0)
          ItemText = Space(TextLength)
          SendMessage(hWndTextBox, WM_GETTEXT, TextLen + 1, ItemText)      
      Loop
  
  End Sub
  </code></pre>