Try
CloseToQuit - Close programs before the system shuts down!
Usage: Add the process name, class or a part of the caption of the programs
you want to close to the apps= line. Separate them by commas.
Any spaces or tabs around the delimiting commas are significant,
meaning that they are part of the match string!
Syntax: apps=[<process name>,<class>,<part of a caption>]
Example: apps=calc.exe,MozillaWindowClass,- Notepad
Skrommel
;CloseToQuit.ahk
; Close programs before the system shuts down
; Usage: Add the process name, class or a part of the caption of the programs
; you want to close to the apps= line. Separate them by commas.
; Any spaces or tabs around the delimiting commas are significant,
; meaning that they are part of the match string!
; Syntax: apps=[<process name>,<class>,<part of a caption>]
; Example: apps=calc.exe,MozillaWindowClass,- Notepad
;Skrommel @ 2008
#NoEnv
#SingleInstance,Force
DetectHiddenWindows,On
SetWinDelay,0
SetBatchLines,-1
apps=calc.exe,MozillaWindowClass,- Notepad
DllCall("kernel32.dll\SetProcessShutdownParameters",UInt,0x4FF,UInt,0)
OnMessage(0x11,"WM_QUERYENDSESSION")
Return
WM_QUERYENDSESSION(wParam,lParam)
{
Global apps
Gui,+LastFound
self:=WinExist()
WinGet,ids,List,,,Program Manager
Loop,%ids%
{
id:=ids%A_Index%
If id=%self%
Continue
WinGet,process,ProcessName,ahk_id %id%
WinGetClass,class,ahk_id %id%
WinGetTitle,title,ahk_id %id%
If process In %apps%
WinClose,ahk_id %id%
Else
If class In %apps%
WinClose,ahk_id %id%
Else
If title Contains %apps%
WinClose,ahk_id %id%
}
ExitApp
}