opening an application using ssh - python

I'm having a pc that i have a python script on it that uses Gui (moves the mouse while searching some opjects). - PC #1
I need to operate this script from another pc (PC #2) in an automation script (that process is just one of the steps, which repeats a lot, but the only one i have issue with).
both are operating with windows.
PC1 can get connection from SSH. and i need to open this script using the PC2. But this script doesn't operate due to gui i think. it's similar to why for example i can't open Matlab or any othe app in PC1 using SSH.
Any way to do it?
Wasn't able to find an answer online. at the moment i use SSH from PC2 (connected using python) to be used with PC1 to run a specific gui locally.

Related

Launching a Windows task using Python event?

I created a Python script that opens a certain software on my PC (the MetaTrader 5 software to be specific), does some processing, saves a file to disk, and closes the software. To have the script running in the background (in hidden / headless / background mode), I was advised to convert the script to a Windows task, since my initial approach using subprocess.Popen() and the STARTUPINFO instance seems to fail for any complex application (see John Hennig's comment under his reply here). Therefore, I created a .bat file and connected it with my new Windows task. Now I hit a roadblock though, since Windows tasks are typically set up with triggering time/frequency to be run automatically. In my case, however, I want the trigger to be an external Python script. Is this possible? If not, is there any other way to have applications run without their windows flashing up on screen?

Automation Scripts Fail when RDP(VM) is minimized

I have been facing issue with automation execution of my script on one of the VM. I have automated the functionality of Saving a Document which is ideally a Windows Designed UI. I have tried using various technologies/tools like AutoIT, Python, Sikuli but the script halts if VM is minimized. It works perfectly fine is VM is open via RDP and I can see runtime execution. But If I minimize the RDP, the script halts at 'Save As' dialog box, none of the send keys (Cntrl+s) or (Enter) work via AutoIt script. Please help with some solution so as to have successfully execution of script even in minimized mode.
The reason why your script fails when it gets executed over a minimized RDP session is quite simple. GUI automation/testing tools need to have an unlocked, active desktop - otherwise the operation system thinks that it doesn't need to actually render GUI operations (which is time consuming) since there no user can that can see the rendered graphical user interface anyway. And programs don't communicate via GUIs normally ...
This is why QF-Test and other GUI automation/testing tools often have a note in their FAQs describing this kind of problem. For example FAQ 14 in the case of QF-Test, see https://www.qfs.de/qf-test-handbuch/lc/manual-en-faq.html
As described in the FAQ 14 on Windows 10 or Windows Server 2016 and in case of an RDP connection you need to modify the Registry. Go to
HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client
and add a new value
RemoteDesktop_SuppressWhenMinimized as DWORD having the value 2
After restarting you will then be able to minimize the RDP connections. However disconnecing or closing the RDP connection will probably still result in a failure.
You could try running tscon.exe RDP-Tcp#0 /dest:console as admin as mentioned here. This will disconnect your RDP connection but should leave all GUI programs running normally on the VM. I have personally used this with autoit on a VM and it worked OK. Of course you will not be able to monitor your script as it runs so this may or may not work for you.

Monitor CPU usage on different machine

As my title goes, I tried to look for something can help me to write the script to get CPU usage from another machine which will be running Virtual Machine(VM), yes I want to get the CPU usage of the VM which runs ubuntu and runs as FTP server. The thing is, I'm still trying to write the script in Python which will be run on Raspberry Pi 2.
I found a few solution that needs me to use bash scripting, but I need to compile with my script of sending ICMP request to the other machine. The thing is I need to write the script instead of using another software. Thank you in advance.
You could maybe try it with VNC but that won't give you a script that will just give you a window into the other machine.

Python remote program execution non-blocking

I have a web application where the user can issue the request to execute a program on a different machine. The web application is written in Python. The remote program is C, but on this side language shouldn't matter.
So SSH is the way to go I think (which has been answered here before). But in my use case the remote program can run for days, and obviously I don't want the ssh call to block my web application.
So I could run the remote program as a background process. But I am also interested in knowing when the program finishes and in the exit code.
So is there any way in achieving this?

Remote Desktop Connection - SetForeground Window not working

I have very similar problem to this one : SetForegroundWindow in Remote Desktop Connection
Everything works when I am connected and watching the RDC, but when I'm not.. Nothing happens.
I am using python and pywinauto, trying to use SendKeys method : SetForegroundWindow returns 0, the same as GetLastError after that, so I have no idea what might cause the trouble.
Edit: I also tried other methods like BringWindowToTop, or SetActiveWindow, also I tried to sent alt key before changing windows - nothing worked.
If your pywinauto script works on remote machine, it cannot manage RDP window at all because RDP window is on your local machine.
To prevent lost of GUI context in RDP you do NOT need to minimize RDP window locally. RDP can lose focus safely, but minimizing leads to stop of any GUI related activity.
It's correct for any GUI automation, not pywinauto only. If you have a lot of test machines, the best way is having 1 master and many slaves. Master host can initiate and keep non-minimized remote sessions, slaves are running GUI automation scripts.

Categories