基本上,这有什么区别
#HotIf MouseIsOver("ahk_class Shell_TrayWnd")
WheelUp::Volume_Up
WheelDown::Volume_Down
#HotIf
; Other code that follows
还有这个?
#HotIf MouseIsOver("ahk_class Shell_TrayWnd")
WheelUp::Volume_Up
WheelDown::Volume_Down
Return
; Other code that follows
另外,我是否需要关闭#HotIf(或返回)?
如果我写这个怎么办?
#HotIf MouseIsOver("ahk_class Shell_TrayWnd")
WheelUp::Volume_Up
WheelDown::Volume_Down
; Other code that follows
Return
在这里不执行任何操作。Return
结束热键块,如下所示:
a::
MsgBox
Return
(想,这不适用于单行热键,就像在您的示例中一样。它们总是只执行一行)
但是在 v2 中,热键块包含在
{ }
中,因此这里不使用 Return
:
a::
{
MsgBox()
}
好的,那么进入下一个问题,为什么需要
#HotIf
?考虑这个
#HotIf WinActive("ahk_exe notepad.exe")
a::MsgBox("notepad specific hotkey 1")
b::MsgBox("notepad specific hotkey 2")
;something else
;something else
MyCoolFunction()
{
;somethingthing
}
MyCoolFunction2()
{
;somethingthing
}
c::MsgBox("Oops, I forgot to end the context sensitive hotkey block, and now this hotkey can only be used in notepad")
你应该做的是:
#HotIf WinActive("ahk_exe notepad.exe")
a::MsgBox("notepad specific hotkey 1")
b::MsgBox("notepad specific hotkey 2")
#HotIf
; something else
; something else
MyCoolFunction()
{
;somethingthing
}
MyCoolFunction2()
{
;somethingthing
}
c::MsgBox("Now I can be used outside of notepad, as intended")