Created
November 8, 2018 22:14
-
-
Save dansmith65/290496063fa1d4ede56cf43f1950c93d to your computer and use it in GitHub Desktop.
Snippets from my main AutoHotkey script to load scripts from a folder, and close them when the main script exists.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Referenced in a comment here: https://portableapps.com/node/39299