title: How to press a key in different program using Python through pycharm
body: <p>I have a program that is always open and every now and again I need to update some background files for it but then I need to hit a key in the program to refresh it. I'm looking for a way to automate that refresh once the updating script has finished.</p>
  <p>What i need to do:</p>
  <blockquote>
  <p>1 - go to the open program on my computer which is called <code>Program</code></p>
  <p>2 - press <code>ctrl + shift + r</code> to perform the refresh</p>
  </blockquote>
  <p>This was a script that I have tried but no such luck from within Pycharm:</p>
  <pre><code>import pyautogui
  from time import sleep
  import subprocess
  
  p = subprocess.Popen(r'C:\Users\xxx\Desktop\xxx\Program.exe')
  pyautogui.keyDown(&quot;ctrl&quot;)
  pyautogui.keyDown(&quot;shift&quot;)
  pyautogui.press(&quot;r&quot;)
  pyautogui.keyUp(&quot;ctrl&quot;)
  pyautogui.keyUp(&quot;shift&quot;)
   
  
  p.kill()
  </code></pre>
  <p>This script keeps me in pycharm and sends me to a find and replace task. Any ideas? thanks!</p>