Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Snippets from my main AutoHotkey script to load scripts from a folder, and close them when the main script exists.
OnExit, ExitSub
;AUTO LOAD SCRIPTS
;==============================================================================
Loop, AutoHotkey.d\*.ahk
{
OutputVarPID =
Run, %A_AhkPath% "%A_LoopFileFullPath%", , , OutputVarPID
CloseProcessesOnExit = %CloseProcessesOnExit%%OutputVarPID%`n
}
; will need hotkey's or something here to keep the script running, otherwise it will immediately exit and close the auto-loaded scripts
;SUBROUTINES
;==============================================================================
;RUN BEFORE EXITING THE SCRIPT
ExitSub:
Loop, parse, CloseProcessesOnExit, `n
If A_LoopField
{
; the if statement filters out the last empty value (created by a trailing `n)
Process, Close, %A_LoopField%
;If (%ErrorLevel% != %A_LoopField%)
; MsgBox, A sub-process could not be closed: %A_LoopField%
}
ExitApp
@dansmith65

This comment has been minimized.

Copy link
Owner Author

dansmith65 commented Nov 8, 2018

Referenced in a comment here: https://portableapps.com/node/39299

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.