title: Simulate alt+tab in Python
body: <p>I'm running in Windows 8.1 this code:</p>
  
  <pre><code>import ctypes, time
  
  ctypes.windll.user32.keybd_event(0x12, 0, 0, 0) #Alt
  ctypes.windll.user32.keybd_event(0x09, 0, 0, 0) #Tab
  
  time.sleep(2)
  
  ctypes.windll.user32.keybd_event(0x09, 0, 2, 0) #~Tab
  ctypes.windll.user32.keybd_event(0x12, 0, 2, 0) #~Alt
  </code></pre>
  
  <p>I expected this code simulate hold the Alt key, hold the Tab key, wait 2 seconds, release Tab key, then release Alt key, but it's not working. The code can't hold the keys, just pulse (press and release) the key. </p>
  
  <p>I've tried this code before and worked, but not in Windows 8.1. What can I do?</p>