Kill any active process

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
User avatar
ravett
Newbie
Posts: 18
Joined: Thu Nov 26, 2020 2:02 am

Kill any active process

Post by ravett » Fri Dec 11, 2020 8:26 pm

Hello

I am familiar with the function "KIllprocess".

But you need to specify constantly a specific process for closing.

Now I have a script for each process. Inconvenient.

Tell me please. A script to close any process whose window is currently active.

Example.
The active window is Chrome. Launched the script - Chrome closed.
Next is the active Calculator window. Launched the script - Calculator is closed.

User avatar
JRL
Automation Wizard
Posts: 3497
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: Kill any active process

Post by JRL » Fri Dec 11, 2020 9:06 pm

You want these three functions.
GetActiveWindow>
GetWindowProcess>
KillProcess>

Or if closing the window closes the process you could also just write a script that presses ALT + F4. Or manually press ALT + F4 rather than bothering with a script.

Press ALT
Press f4
Release ALT

User avatar
ravett
Newbie
Posts: 18
Joined: Thu Nov 26, 2020 2:02 am

Re: Kill any active process

Post by ravett » Fri Dec 11, 2020 9:18 pm

JRL wrote:
Fri Dec 11, 2020 9:06 pm
You want these three functions.
GetActiveWindow>
GetWindowProcess>
KillProcess>

Or if closing the window closes the process you could also just write a script that presses ALT + F4. Or manually press ALT + F4 rather than bothering with a script.

Press ALT
Press f4
Release ALT
Brilliant!
As I myself did not guess :(

Thank you!

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts