Reputation: 541
I have made a python script based on the pyautogui
module, which controls my mouse and keyboard and can automate some tasks I have at work.
However, sometimes, it doesn't really go as planned and I have to stop the script (even though it might be in the middle of something). The problem is that the terminal window is not in front anymore, so I cannot press ctrl+c.
I have heard that it is possible to use ctrl+break as well, but it does not seem to work (might be because I have to run the script inside of a remote desktop connection). And the failsafe on pyautogui
is to drag the mouse to the top left corner, but it does not seem to work in a remote desktop connection as well.
Is there some way I can add my own failsafe, or some keyboard combination I can try to stop the ongoing python script, even though the terminal is not accessible?
Upvotes: 0
Views: 694
Reputation: 464
On Windows systems, try ctrl+alt+end. This will open the task manager on the computer you are Remote Desktop'd into.
Upvotes: 1
Reputation: 2479
Assuming you're on *nix-like system: just run pkill python
in a new terminal to kill all python processes of your user.
You can run:
ps ax
to find the exact process you want to kill then
kill -9 <the PID of your process>
To start a new tty you can press ctrl + F4 then log in
If you're on windows: ctrl+alt+del to the task manager then seek your python process and kill it
Upvotes: 1