1

I want to automate a very old software (drafix) that can only be run in Windows XP, on a remote desktop.

Would it be possible to write a pywinauto script that would directly interact with the software controls, without the need to send mouse/keyboard clicks on the GUI, and then minimize the Remote Desktop screen or even lock the PC?

I need to open the program, loop through a list of file names, open each one of them and save as a different format.

I did it with some basic GUI automation - clicking on buttons if necessary, sending keyboard shortcuts and entering the file names form a list. But it isn't very reliable, and I would like to minimize the Remote Desktop window and use my PC instead of having it in the foreground.

From what I have read here, it should be possible with some workarounds, and I would need to install an older version of Python (any idea which one?) on the remote desktop to write and run the script there.

Sargro
  • 15
  • 1
  • 5

2 Answers2

2

What you can do is just copying your script to remote machine and run it there. Regarding minimized or closed RDP there are few workarounds and tricks described in the Remote Execution Guide which summarizes few StackOverflow answers.

Vasily Ryabov
  • 9,386
  • 6
  • 25
  • 78
  • Thank you. The problem is that I want to use SWAPY or py_inspect to correctly identify the controls, and do the debugging on the machine, without having to move the script back and forth between the machines – Sargro Apr 03 '19 at 11:12
  • RDP doesn't provide any GUI elements info to local machine. So in your case all debugging should happen on remote machine only. – Vasily Ryabov Apr 03 '19 at 11:46
  • By the way, you have to uninstall comtypes on Windows XP: `pip install pywinauto`, then `pip uninstall -y comtypes`. This is needed because `UIAutomationCore.dll` is not present on WinXP so `backend="uia"` is not available. If you need `backend="uia"`, you have to install .NET Framework 3.5 or later available for WinXP. – Vasily Ryabov Apr 03 '19 at 11:48
  • 1
    I have managed to make it work - used swapy to inspect the controls, and programmed them on my own machine, then just used pyinstaller to prepare an executable. The real challenge was making it work on XP - but your hint about comtypes helped, had to add `--hidden-import comtypes, comtypes.gen,comtypes.patcher, comtypes.GUID` to the pyinstaller options, and prepare everythin in a 32bit Python 3.4 environment - miniconda helped here. Thank you Vasily! – Sargro Apr 04 '19 at 12:14
  • You're welcome. I'm planning to fix it in the library later: https://github.com/pywinauto/pywinauto/issues/703 – Vasily Ryabov Apr 06 '19 at 14:57
0

There is other way that you can control gui application on remote Desktop with pywinauto. You can use rpyc or Remote Python Call. that is a python library for rpc(remote procedure call)

https://rpyc.readthedocs.io/en/latest/

your remote computer is as server and your host is as client in rpyc.

first you you need to run rpyc_classic.py in remote computer after connect to it and use pywinauto library. for example i use rpyc for start microsip on remote computer with pywinauto.

ip of remote computer is 192.168.222.222.

import rpyc
ip = "192.168.222.222"
conn = rpyc.classic.connect(ip)
conn.execute("from pywinauto import Application")
conn.execute(r"Application().start(r'C:\Program Files (x86)\MicroSIP\microsip.exe')")
GreenMan
  • 269
  • 1
  • 15