title: Set focus to window based on ID using win32com.client's AppActivate
body: <p>I've tried the following, but focus isn't returned to the program that had focus when the script was run:</p>
  
  <pre><code>import win32com.client
  import win32gui
  
  current = win32gui.GetForegroundWindow()
  
  shell = win32com.client.Dispatch("WScript.Shell")
  
  shell.AppActivate('Console2')
  
  shell.SendKeys('{UP}{ENTER}')
  
  shell.AppActivate(str(current))
  </code></pre>