¿Cómo cerrar todos los scripts en ejecución y reiniciarlos más tarde?

¿Cómo cerrar todos los scripts en ejecución y reiniciarlos más tarde?

Para actualizar AutoHotkey, se deben cerrar todos los scripts en ejecución. Los procesos de AutoHotkey se pueden eliminar con un script simple (ver más abajo), pero no sé cómo reiniciarlos a voluntad. Actualmente reinicio mi computadora después de la actualización (para iniciar los scripts AHK en la carpeta de inicio de Windows).

Aparentemente, Windows no permite ejecutar varios archivos simultáneamente. Debido a que tengo docenas de scripts AutoHotkey habilitados, no es posible iniciarlos manualmente.

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

Loop
{
#Singleinstance force
Process, Close, Autohotkey.exe
}

Respuesta1

; FileDelete, %A_Desktop%\my running scripts.ini

; Get a list of all running AHK scripts:
DetectHiddenWindows, ON
WinGet, id, list, ahk_class AutoHotkey 
Loop, %id% ; retrieves the  ID of the specified windows, one at a time
{
    this_ID := id%A_Index%
    WinGetTitle, title, ahk_id %this_ID%    
    SkriptPath := RegExReplace(title, " - AutoHotkey v" A_AhkVersion )
    If InStr(SkriptPath, A_ScriptFullPath)
        continue
    ; Store the path of each running script in an INI-file and terminate it:
    IniWrite, %SkriptPath%`n, %A_Desktop%\my running scripts.ini, my_running_scripts
    WinClose, %SkriptPath% ahk_class AutoHotkey 
}
; Run %A_Desktop%\my running scripts.ini

; Create a new script in the startup folder that starts the same scripts after rebooting:
FileAppend, 
(
    IniRead, my_running_scripts, `%A_Desktop`%\my running scripts.ini, my_running_scripts
    Loop, parse, my_running_scripts, ``n
        Run `%A_LoopField`%
    ; FileDelete, `%A_ScriptFullPath`%
    ExitApp
)
, %A_Startup%\my running scripts.ahk
ExitApp
return

Reemplace %A_Startup%con %A_Desktop%si desea reiniciar los scripts manualmente desde su escritorio.

información relacionada