How to restore a window in RDP using pywinauto, when RDP is in Minimized state

这一生的挚爱 提交于 2019-12-24 23:59:30

问题


I have been using pywinauto for opening a command prompt (Mingw-64) and was passing commands using type_keys

It was working properly in my local system but, when i hosted my code into RDP server, i am not able to restore the window and pass the commands when RDP is in minimized state

Please give me a proper solution and let me know if any package does the same purpose.

Thanks!


回答1:


There are several points to improve.

  1. It's better to use standard Python module subprocess with stdin re-direction to communicate with a command line application. I'd highly recommend you this way which is resistant to RDP minimizing.

  2. RDP doesn't provide GUI context in minimized state (any GUI automation tool will give up here). To workaround it simply switch RDP from full-screen mode to restored window state (non-minimized!), run your GUI automation script inside RDP window and quickly switch to your local machine (to another window) and continue your work without affecting the automation script. Just don't ever minimize RDP. It's a manual quick hack, if you do it rarely.

  3. Third thing to automate is using command psexec with key -i (interactive). This way you can run remote commands with GUI context automatically without manual hacks. Just find and download PsexecTools (recommended) or learn similar commands for Power Shell.

  4. To eliminate this problem at all just use VNC Server software like TightVNC instead of RDP. If you used RDP at least once, you have to reboot the remote machine though. One more possible pitfall is the fact that VNC display is not virtual (like RDP session), hence it requires to have relevant display drivers for your video card. Otherwise you may face with black screen or small resolution. The big plus of VNC that it keeps GUI context even if you disconnect from current session (i.e. closed your laptop before going home).




回答2:


Useful answer can be found there: https://support.smartbear.com/testcomplete/docs/testing-with/running/via-rdp/in-minimized-window.html

And this must be done to disconnect from RDP without effect:

To disconnect from Remote Desktop, run the following command on the remote computer (in the Remote Desktop window) as an Administrator:

%windir%\System32\tscon.exe RDP-Tcp#NNN /dest:console

where RDP-Tcp#NNN is the ID of your current Remote Desktop session, for example, RDP-Tcp#0. You can see it in the Windows Task Manager on the Users tab, in the Session column.

You will see the “Your remote desktop session has ended” message, and the Remote Desktop client will close. But all programs and tests on the remote computer will continue running normally.



来源:https://stackoverflow.com/questions/47137372/how-to-restore-a-window-in-rdp-using-pywinauto-when-rdp-is-in-minimized-state

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!