问题
I've got Mac OSX running and want to programmatically manipulate a active RDP session to for instance, perform actions within a launched program within the session (dynamics specifically, yet woudn't hurt to know a universal way).
I don't know if this is possible. Currently using a RDP file to launch the RDP session with credentials and have the process ID of my active session, retrieved via NSWorkspace. With that I can do the basic stuff like closing my session again, yet i want to manipulate the session.
My RDP client currently is Microsoft Remote Desktop.
Would wish to reach my goal in either bash or python.
回答1:
Here are few ideas:
- Use Quartz graphics library in Python to manipulate with RDP client window. Here is a good start: How to list all windows from all workspaces in Python on Mac?
- Use libfreerdp via ctypes.
- Run RDP session under Wine and use tools such as AutoHotKey, AutoIT or xdottool. See: How to programmatically control X11 forwarded apps?
- Use WinRM (pywinrm) instead of RDP to run remote commands/scripts. Check this example. This can allow to run auto tools mentioned above (e.g. AHK script controlling the apps).
- Use Python GUI automation library for simulating user interaction in apps.
- See also: GUI scipting for Linux.
- Write an RDP client that dumps the pixels of the screen. E.g. WebRTC or using libFreeRDP.
- If RDP client runs via X11 protocol (Quartz), you can try to tap into X11 requests as per this post.
- Use FreeRDP and its API. Its client is compatible with Linux, macOS and Windows.
来源:https://stackoverflow.com/questions/34630826/programmatically-manipulating-active-rdp-session