如何将热键绑定放置在自动执行脚本的 start/top 而不是末尾?
How can I place Hotkey bindings at the start/top of an autoexecuting script rather than the end?
通常,“加载脚本后,[AutoHotKey] 从第一行开始执行,一直持续到 Return、退出、hotkey/hotstring 标签或脚本的物理结束遇到(以先到者为准)。
但是,我想将我的热键触发器 放在自动执行部分 上方,以便于阅读 and/or 使最终用户更容易编辑他们喜欢的热键。我该怎么做?
很简单。简单地给你的自动执行部分一个标签,并在你的第一个热键绑定之前使用 goto
命令来跳过解析这些热键作为自动执行的一部分。
示例:
#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.
UserVariableOne := 3.14
UserVariableTwo := true
UserVariableThree := "Banana"
goto BeginTheScript
^Space::
Msgbox, I am a Hotkeyed Messagebox! %UserVariableOne%
return
+Space::
Msgbox, I am another Hotkeyed Messagebox! %UserVariableTwo%
return
Esc::Exitapp
BeginTheScript:
Msgbox, I am an Auto-execute Messagebox! %UserVariableThree%
return
或者,您只需在脚本的开头添加一个 return 语句
以例:
#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.
UserVariableOne := 3.14
UserVariableTwo := true
UserVariableThree := "Banana"
return ; <---This line here<<
^Space::
Msgbox, I am a Hotkeyed Messagebox! %UserVariableOne%
return
+Space::
Msgbox, I am another Hotkeyed Messagebox! %UserVariableTwo%
return
Esc::Exitapp
通常,“加载脚本后,[AutoHotKey] 从第一行开始执行,一直持续到 Return、退出、hotkey/hotstring 标签或脚本的物理结束遇到(以先到者为准)。
但是,我想将我的热键触发器 放在自动执行部分 上方,以便于阅读 and/or 使最终用户更容易编辑他们喜欢的热键。我该怎么做?
很简单。简单地给你的自动执行部分一个标签,并在你的第一个热键绑定之前使用 goto
命令来跳过解析这些热键作为自动执行的一部分。
示例:
#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.
UserVariableOne := 3.14
UserVariableTwo := true
UserVariableThree := "Banana"
goto BeginTheScript
^Space::
Msgbox, I am a Hotkeyed Messagebox! %UserVariableOne%
return
+Space::
Msgbox, I am another Hotkeyed Messagebox! %UserVariableTwo%
return
Esc::Exitapp
BeginTheScript:
Msgbox, I am an Auto-execute Messagebox! %UserVariableThree%
return
或者,您只需在脚本的开头添加一个 return 语句
以例:
#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.
UserVariableOne := 3.14
UserVariableTwo := true
UserVariableThree := "Banana"
return ; <---This line here<<
^Space::
Msgbox, I am a Hotkeyed Messagebox! %UserVariableOne%
return
+Space::
Msgbox, I am another Hotkeyed Messagebox! %UserVariableTwo%
return
Esc::Exitapp