AutoHotkey を更新するには、実行中のスクリプトをすべて閉じる必要があります。AutoHotkey プロセスは簡単なスクリプト (下記参照) で終了できますが、同じプロセスを任意に再起動する方法がわかりません。現在、更新後にコンピューターを再起動しています (Windows スタートアップ フォルダー内の AHK スクリプトを起動するため)。
Windows では、複数のファイルを同時に起動できないようです。数十の AutoHotkey スクリプトが有効になっているため、手動で起動するのは不可能です。
#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
}
答え1
; 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
デスクトップからスクリプトを手動で再起動する場合は、%A_Startup%
に置き換えます。%A_Desktop%