title: Accessing a dialog box's handle and automatically manipulating the user interface
body: <p>I have some VB code which makes use of a COM api and results in a certain dialog box popping up on the screen. My program is a console application, that needs to run in a batch file, but I haven't found any other way to do things other than finding a way to automatically manipulate the dialog box.</p>
  
  <p>Here is the api call (omitting setup code) that results in the dialog popping up:</p>
  
  <pre><code>  Dim oScript = New ProvideX.Script()
  
    ' Setup code here '
  
    oScript.Run(commName)
  </code></pre>
  
  <p>This method has no return value, and no extra parameters that would enable me to fill in the values I need through the API.</p>
  
  <p>I have found one method to get the handle of the dialog window, but I'm not sure if it will work, or if it will grab onto the Command line window instead. </p>
  
  <pre><code>Dim windowHandle = Process.GetCurrentProcess().MainWindowHandle
  </code></pre>
  
  <p>Is there any way to get a list of windows that were created by my process so I can identify the one that corresponds to my dialog?</p>
  
  <p>Also, can anyone point me in the right direction of how to do send mouse clicks and keyboard presses to an unmanaged dialog box, or is there some better way to do what I need.</p>
  
  <p>This is a fairly simple dialog box that has a warning prompt that needs to be accepted by clicking on an ok button. Then there are two text boxes that need to be filled out with data I have. And then I need to click on another button.</p>
  
  <p>I'm not asking for a complete answer, I'm just looking for the general jist of how to do it.</p>
  
  <p>Edit: I was doing research at PINVOKE.net and I think SendInput will work if I can get the right handle. I've walked through the dialog and it can all be handled by keyboard input.</p>