title: Using window handles (win32gui) instead of captions in python
body: <pre><code>import win32ui
  import win32gui
  
  def WindowExists(windowname):
      try:
          win32ui.FindWindow(None, windowname)
          
      except win32ui.error:
          return False
      else:
          return True
  
  hwndName = &quot;Main Window Program&quot;
           
  if WindowExists(hwndName):
      print (&quot;Program is running&quot;)
      hwnd = win32gui.FindWindow(None, hwndName)   
  else:
      print (&quot;Program is not running&quot;)  
  
  child_handles = []
  
  def all_ok(hwnd, param):
      child_handles.append(hwnd)    
              
  win32gui.EnumChildWindows(hwnd, all_ok, None)
  
  print (child_handles)
  </code></pre>
  <p>The code above is working perfectly fine for me to be able to detect if &quot;Main Window Program&quot; is running, I am also able to enumerate all the child windows off of that. My problem however is I dont know how to use handles instead of captions, so instead of <code>hwnd = &quot;Main Window Program&quot;</code> I could use <code>hwnd = 0xC0D57</code> (or whatever the handle is).</p>
  <p>Also whats the best input method do a control? postmessage, sendmessage etc?</p>