title: How do I use win32gui and win32api to locate and move a window in windows, using python
body: <p>This issue really arises from me not understanding what I have to pass to win32gui.EnumWindows()</p>
  
  <p><a href="http://timgolden.me.uk/pywin32-docs/win32gui__EnumWindows_meth.html" rel="nofollow noreferrer">http://timgolden.me.uk/pywin32-docs/win32gui__EnumWindows_meth.html</a></p>
  
  <p>The short version of what Im trying to accomplish:</p>
  
  <ol>
  <li>Detect a window that may be on any of 4 different monitors (my remote desktop window, not anything actually running on the remote desktop)</li>
  <li>Move the window to a certain monitor (I can find the monitor HANDLE already)</li>
  <li>Maximize the window</li>
  </ol>
  
  <p>I would like to accomplish this via win32gui and win32api</p>
  
  <p>I do however have a possible other method:
  If anyone knows how to make pyautogui screenshot functions observe anything other than the primary display, then it would be possible to </p>
  
  <p>Use pyautogui to detect the remote desktop window header (always the same, but could appear on 4 monitors, then click on it and drag to proper monitor and maximize with pyautogui.</p>
  
  <p>and a third method:</p>
  
  <p>Use pygetwindow to locate and bring to focus the remote desktop window, then use win32api to move that to the proper monitor.  I would need a way to use win32 to get the HANDLE of the focused window.</p>
  
  <p>EDIT: I was able to get WHAT I THOUGHT was the right handle using </p>
  
  <p><code>pygetwindow.getAllTitles()</code> to find the title of the remote desktop program, then using <code>pygetwindow.getWindowsWithTitle('MyRemoteDesktopName - Remote Desktop Connection')</code> since 'MyRemoteDesktopName - Remote Desktop Connection' was listed as the title before.  This provided me with a handle that I used 
  <code>win32gui.MoveWindow(197160, 0, 0, 1920, 1080, True)</code> to move the window to my original screen.  HOWEVER, the remote desktop bar did not move,a nd the screen, while it now fit, did not rescale the way dragging the bar to another window would have.  Each of my monitors has a different size and resolution and my remote desktop auto scales to match whatever I drag the bar to.  But when I use wMoveWindow, it disconnects from that bar</p>