Close application with AHK if another application is closed

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
alesyt0h
Posts: 214
Joined: 28 Jan 2015, 20:37

Close application with AHK if another application is closed

28 Jan 2015, 20:41

Hello!

I have an script that runs some applications in each hotkey, but when I close the main application I want them to close.. I have this, and it works, but only for 1 application, can't close more than 1 application with this:

Code: Select all

SetTimer, ProcessCheckTimer, 1000
Return

ProcessCheckTimer:
Process, Exist, MainApp.exe
pid1 := ErrorLevel
Process, Exist, MainApp64.exe
pid3 := ErrorLevel

If (!pid1 && !pid3)
{
   Process, Exist, LENd.exe
   pid2 := ErrorLevel
   If (pid2)
      Process, Close, %pid2%
   ExitApp 
}
Return
I need the script to close LENd.exe & L3Rd.exe & Clicker.exe(Another AHK script) & SReader.exe

How to do it?

Thank you so much!

Regards
User avatar
boiler
Posts: 16977
Joined: 21 Dec 2014, 02:44

Re: Close application with AHK if another application is clo

28 Jan 2015, 21:22

If you have a GUI, use GuiClose: before your code that closes those processes if they exist. And if you don't, you could add one just so that it creates this event.
alesyt0h
Posts: 214
Joined: 28 Jan 2015, 20:37

Re: Close application with AHK if another application is clo

28 Jan 2015, 21:39

Thanks for reply!

I don't have a GUI.. the code I posted above is fine, just need to add more applications to the if and I don't know how to do it :(
User avatar
boiler
Posts: 16977
Joined: 21 Dec 2014, 02:44

Re: Close application with AHK if another application is clo

28 Jan 2015, 21:51

I don't understand the issue then. Why wouldn't you just repeat everything from Process, Exist, LEnd.exe down to Process, Close, %pid2% for each process, but just replace the name of the .exe and change the variable from pid2 to pid4, pid5, and how ever many you want?
alesyt0h
Posts: 214
Joined: 28 Jan 2015, 20:37

Re: Close application with AHK if another application is clo

28 Jan 2015, 22:05

Thanks for reply!
Of course I did! But don't work.. only closes the first one.

Tried it in many ways.. :(
MJs
Posts: 454
Joined: 23 Sep 2014, 03:29

Re: Close application with AHK if another application is clo

28 Jan 2015, 22:48

can't say, I fully understand what you do but:

Code: Select all

PROCESSES=LENd.exe,L3Rd.exe,Clicker.exe,SReader.exe ; string with all of you processes to go through
SetTimer, ProcessCheckTimer, 1000
Return

ProcessCheckTimer:
Process, Exist, MainApp.exe
pid1 := ErrorLevel
Process, Exist, MainApp64.exe
pid3 := ErrorLevel

If (!pid1 && !pid3)
{
	Loop, Parse, PROCESSES, CSV ; parse the PROCESSES string, string seperated by a comma
	{
		Process, Exist, %A_LoopField%
		pid2 := ErrorLevel
		If (pid2)
			Process, Close, %pid2%
  }
   ExitApp
}
Return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: mikeyww and 353 guests