title: Control mouse on remote windows server
body: <p>I need to run GUI application on remote windows host and then do some actions with mouse and keyboard. This should be done from local pc without opening any GUI application (for example "Remote Desktop Connection").</p>
  
  <p>So I have a python script on remote server which does all the actions I need (tested on local pc) and I run the script via psexec which successfully opens the GUI application on server.</p>
  
  <p><strong>The problem is that when python tries to programatically move and click mouse it throws an exception because there is no screen.</strong></p>
  
  <p>Actions with keyboard (Ctrl-A, Ctrl-C, Ctrl-V) can be done successfully.</p>
  
  <p>Here is the code that I use to simulate mouse click but as I mentioned it doesn't work on server because there is no actual screen.</p>
  
  <pre><code>win32api.SetCursorPos((x,y))
  win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,x,y,0,0)
  win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,x,y,0,0)
  </code></pre>
  
  <p>Can anyone suggest me a solution?</p>