Search code examples
python-3.xremote-desktoppyautogui

Pyautogui on RDP


I am using pyautogui in Windows 10 with Python 3, in a virtual machine accessed by remote desktop.

Unfortunately, the program stops execution when I close remote connection, giving "OSError: screen grab failed".

I've searched for a solution online, but the only workaround that I've found is from this link

Use a remote desktop client that allows you to keep outputting the display, even if you minimise the window/close your PC. I used terminals (https://terminals.codeplex.com/ - not affiliated with them at all just recommending as it solved this issue for me).You can set this up to persist the display, and your code should then run fine.

The problem is that I can't find a setting for persisting display. I've also found this:

pyautogui._pyautogui_x11._display = Xlib.display.Display(
            os.environ['DISPLAY']
        )

... but it doesn't seems to work either (gives me errors...).

Do you have some workaround to do the trick?


Solution

  • I have resolved using TightVNC instead of remote desktop and detaching mouse cursor.