closing all instances

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
AmDeG 11
Posts: 388
Joined: 28 Nov 2013, 11:42

closing all instances

25 May 2017, 21:12

the following script closes an instance of IrfanView

what should I do in order to close ALL IrfanView instances?

Code: Select all

#IfWinExist ahk_class IrfanView 
+^space:: WinClose ahk_exe i_view64.exe
#IfWinActive
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: closing all instances

25 May 2017, 21:30

Maybe like this:

Code: Select all

#IfWinExist ahk_class IrfanView 
+^space::
    Loop
	{
        if WinExist("ahk_exe i_view64.exe")
		{
            WinClose, ahk_exe i_view64.exe
			WinWaitClose, ahk_exe i_view64.exe
		}
		else
			break
		Sleep 100
    }
return
#IfWinActive
AmDeG 11
Posts: 388
Joined: 28 Nov 2013, 11:42

Re: closing all instances

25 May 2017, 23:40

sorry it is not working

also at my original post I think I was wrong not closing the code with #IfWinExist
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: closing all instances

26 May 2017, 01:32

Remove WinWaitClose, ahk_exe i_view64.exe from what i posted and it should work.
TheEnemy
Posts: 94
Joined: 28 Jan 2016, 09:54

Re: closing all instances

26 May 2017, 07:41

Code: Select all

process=i_view64.exe
Process, Exist, %process%
if	pid :=	ErrorLevel
{
	Loop 
	{
		WinClose, ahk_pid %pid%, , 2	; will wait 2 sec for window to close
		if	ErrorLevel	; if it doesn't close
			Process, Close, %pid%	; force it 
		Process, Exist, %process%
	}	Until	!pid :=	ErrorLevel
}
return

^x::
ExitApp ;press ctrl-X to close the script, until you come up with your own way.
Hope this works for you.
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: closing all instances

26 May 2017, 07:48

Try this:

Code: Select all

+^Space::
    While WinExist("ahk_class IrfanView")
        WinClose
Return
I hope that helps.
AmDeG 11
Posts: 388
Joined: 28 Nov 2013, 11:42

Re: closing all instances

26 May 2017, 08:27

@wolf_II

yours, works, thanks

However I would like to enclose +^Space just when Irfan is active

how should I tweak the script?
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: closing all instances

26 May 2017, 08:35

Try this:

Code: Select all

#IfWinActive, ahk_class IrfanView
+^Space::
    While WinExist("ahk_class IrfanView")
        WinClose
Return
#If ; off 
 
I hope that helps.
AmDeG 11
Posts: 388
Joined: 28 Nov 2013, 11:42

Re: closing all instances

26 May 2017, 15:21

well I want to use it always except two exceptions but I cannot make it work with the two exceptions

Code: Select all

#If WinNotActive {"ahk_class AHK.ahk * SciTE4AutoHotkey"} or WinNotActive {"ahk_class TTOTAL_CMD"}
+^Space::
    While WinExist("ahk_class IrfanView")
        WinClose
Return
#If

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 337 guests