Wie schließe ich alle laufenden Skripte und starte sie später neu?

Wie schließe ich alle laufenden Skripte und starte sie später neu?

Um AutoHotkey zu aktualisieren, müssen alle laufenden Skripte geschlossen werden. AutoHotkey-Prozesse können mit einem einfachen Skript beendet werden (siehe unten), aber ich weiß nicht, wie ich dieselben Prozesse nach Belieben neu starten kann. Derzeit starte ich meinen Computer nach der Aktualisierung neu (um die AHK-Skripte im Windows-Autostart-Ordner zu starten).

Windows erlaubt anscheinend nicht das gleichzeitige Starten mehrerer Dateien. Da ich Dutzende von AutoHotkey-Skripten aktiviert habe, ist es nicht möglich, sie manuell zu starten.

#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
}

Antwort1

; 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

Ersetzen Sie %A_Startup%es durch %A_Desktop%, wenn Sie die Skripte manuell von Ihrem Desktop aus neu starten möchten.

verwandte Informationen