title: Image Grab Failed by Minimizing(or Closing) Remote Connection or Running too Many Times
body: <p>I wrote a code, and I want to run it in a server. I use windows remote connection for connecting to this server. I have some problems. </p>
  
  <ol>
  <li><p>I want to run Image Grab for taking screenshot's too many times(approximately 3 times each second) for 7 hours. I use <code>Pyautogui</code> package for screenshot. But when this program ran, an error occurred and program stops execution. </p>
  
  <p><code>IOError: screen grab failed</code></p></li>
  </ol>
  
  <p>I used other packages(like python <code>ImageGrab()</code>) also, but it occurred again.</p>
  
  <ol start="2">
  <li>When I want to close or minimize my remote connection, that error occurred again. So I could not close or minimize remote windows.</li>
  </ol>
  
  <p>Code: I summarized my code for better understanding.</p>
  
  <pre><code>import pyautogui
  import time
  i=0
  while(True):#i&lt;200000
      im=pyautogui.screenshot()
      time.sleep(0.3)
      i+=1
      """"""
      """Main Algorithm""" 
  </code></pre>
  
  <p><strong>Comment:</strong> I use <code>Pyautogui</code> package because it take screenshots too fast.</p>