Process Close Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
wav
Posts: 5
Joined: 08 Aug 2020, 20:47

Process Close

08 Aug 2020, 21:01

Hello experts! Newbie looking for some assistance. Basically I have a process that I would like to kill only if another ahk_class does not currently exist, if it does do nothing.

The two ahk_class in question use the same executable but different windows open different ahk_class according to Window Spy.

So what I'd like to see is..

If ahk_class ProgramABC & ahk_class ProgramXYZ exist do nothing.

If only ahk_class ProgramXYZ exist process close the executable.

Thanks
Rohwedder
Posts: 3377
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Process Close

09 Aug 2020, 03:28

Hallo,
try:

Code: Select all

q::
IF WinExist("ahk_class ProgramABC")
	Return ;does do nothing
WinGet, PID, PID, ahk_class ProgramXYZ
Process, Close,% PID
Return
wav
Posts: 5
Joined: 08 Aug 2020, 20:47

Re: Process Close

14 Aug 2020, 21:10

Sorry I didnt notice the response and no email...weird.

Anyways, your script worked perfectly, thank you! Can you show me how to wrap it up in a loop that runs this check every hour?
Epialis
Posts: 235
Joined: 02 Aug 2020, 22:44

Re: Process Close  Topic is solved

15 Aug 2020, 11:51

@Wav


Simple timer is all you need.

Code: Select all

SetTimer, check, 1000 ; 1 second... 10000 (10 seconds) ..
; do other stuff here
return

check:
If WinExist, ("ahk_class Chrome_WidgetWin_1")
Return
	process, close, chrome.exe
return
ExitApp
wav
Posts: 5
Joined: 08 Aug 2020, 20:47

Re: Process Close

18 Aug 2020, 17:44

That works like a champ. Thank you!

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], Dario91, Google [Bot], Milenko, sebbulon, TAC109 and 29 guests