使用标志在 Autohotkey 中切换热键
Toggle Hotkeys in Autohotkey by using a flag
我希望能够打开和关闭我的热键。我有像 "a=f" 或 "d=y" 这样的热键映射。我希望能够按一个键并将 "a=a" 切换为 "a=f" 并返回。现在我正在为此使用暂停键。问题是:当我想取消暂停时,我必须用鼠标手动执行此操作,然后右键单击取消暂停(因为我的自定义热键不再是 运行,所以我拥有的取消暂停的键是无法识别,因为脚本已暂停)。
我的简单想法是为挂起和挂起设置一个全局热键。但是我还没有找到类似的东西。
因此我做了一个布尔标志来手动切换。为此,我不需要暂停。但是只要有一把钥匙,就可以切换标志。这是一些示例代码:
if (flag)
{
a::f
}
else
{
a::a
}
我收到重复的热键错误。
切换变量值:
flag := !flag
将根据其当前值使标志为真或假。真变假,反之亦然。
flag := false ; initialize variable
F1:: flag := !flag ; press F1 to toggle the variable's value to true/false
; The #If-directive creates context-sensitive hotkeys and hotstrings:
#If (flag) ; if this variable has the value "true"
a::f
#If ; turn off context sensitivity
https://autohotkey.com/docs/commands/_If.htm
https://autohotkey.com/docs/Variables.htm#Expressions
我希望能够打开和关闭我的热键。我有像 "a=f" 或 "d=y" 这样的热键映射。我希望能够按一个键并将 "a=a" 切换为 "a=f" 并返回。现在我正在为此使用暂停键。问题是:当我想取消暂停时,我必须用鼠标手动执行此操作,然后右键单击取消暂停(因为我的自定义热键不再是 运行,所以我拥有的取消暂停的键是无法识别,因为脚本已暂停)。
我的简单想法是为挂起和挂起设置一个全局热键。但是我还没有找到类似的东西。
因此我做了一个布尔标志来手动切换。为此,我不需要暂停。但是只要有一把钥匙,就可以切换标志。这是一些示例代码:
if (flag)
{
a::f
}
else
{
a::a
}
我收到重复的热键错误。
切换变量值:
flag := !flag
将根据其当前值使标志为真或假。真变假,反之亦然。
flag := false ; initialize variable
F1:: flag := !flag ; press F1 to toggle the variable's value to true/false
; The #If-directive creates context-sensitive hotkeys and hotstrings:
#If (flag) ; if this variable has the value "true"
a::f
#If ; turn off context sensitivity
https://autohotkey.com/docs/commands/_If.htm https://autohotkey.com/docs/Variables.htm#Expressions