title: Python simulating 'enter' keypress in a game
body: <p>So I've been attempting to get a script to type out a string of text in a video game (Guild Wars 2). Mainly I'm using pyautogui and for the most part it works fine. My issue is it seems I can't get the game to recognize 'enter'. For example if I have the code:</p>
  
  <pre><code>import pyautogui, time
  time.sleep(2) #to allow me to have time to switch windows
  pyautogui.press('enter')
  pyautogui.typewrite("This is a test")
  pyautogui.press('enter')
  </code></pre>
  
  <p>The two "press enter" function will not open and submit the text. If however I manually hit enter, the 3rd line types things out just fine.</p>
  
  <p>I've also tried replacing press('enter') with keyDown followed by keyUp, but with still no results.</p>
  
  <p>I've managed to create a workaround by having python hit F10, and then a separate Autohotkey script hitting enter when F10 is hit, but that is far from ideal. Are there any suggestions?</p>
  
  <p>Extra note from comments: The script by itself works fine in other programs such as notepad. It seems to fail exclusively for the game client.</p>