假设我C:\path\to\my\script
正在运行一个自动热键脚本。有没有办法定义一个重新启动它的热键?
问问题
12513 次
3 回答
14
为了防止重复实例,我通常不会重新启动脚本,而是使用内置函数Reload。我使用 + + + 启动它并使用 + + +编辑Ctrl主AHK脚本。WinAltRCtrlWinAltE
^#!r::Reload
实际上,我的脚本如下所示:
^#!r::
Send, ^s ; To save a changed script
Sleep, 300 ; give it time to save the script
Reload
Return
^!#e::Edit
事实上,一直到我的脚本顶部,我都有这个给我一个视觉和音频指示脚本已重新启动:
#SingleInstance Force
#installKeybdHook
#Persistent
Menu, Tray, Icon , Shell32.dll, 25, 1
TrayTip, AutoHotKey, Started, 1
SoundBeep, 300, 150
Return
于 2013-03-29T18:28:36.973 回答
1
制作一个运行脚本的热键,在这种情况下是相同的脚本,然后退出。
somehotkey::
Run, C:\path\to\my\script.ahk
ExitApp
return
于 2013-03-29T15:46:30.513 回答
0
I found this to be the safest option of them all, because it takes care that the correct script is reloaded when you have multiple scripts running simultaneously, which was a recurring issue for me. The combination of the following also ensures that only one instance of a script will ever run at a time. The ScriptFullPath variable includes the name of the script.
#SingleInstance Force ;put this at the top of the script
^r::run, %A_ScriptFullPath%
于 2019-04-18T15:23:14.700 回答