AutoHotKey IfWinActive 不工作
AutoHotKey IfWinActive not working
我正在尝试使用一个简单的脚本,该脚本仅在活动 window 打开并且您处于该 window 时才有效(例如某些 windowed 模式游戏)。所以脚本可以工作,但它也可以在活动 window 之外工作,例如在桌面或浏览器上。我不需要那个。我只需要它在我设置的活动 window 中工作。
脚本:
RButton::rightMouseClick()
rightMouseClick(){
if WinActive("ahk_class Notepad") {
WinMaximize
Send, Some text.{Enter}
return
}
}
因此,当您转到记事本并右键单击时,此示例有效。但是现在右键单击在计算机上的其他任何地方都不起作用?只有按住 shift 才有效?!
如何使此脚本 react/work/run 仅当活动 window 是记事本时?并且不在全球范围内工作。
#IfWinActive ahk_class Notepad
RButton::
WinMaximize
Send, Some text.{Enter}
Return
#If
这是我的建议:
#If WinActive("ahk_class Notepad") ;if the window with the ahk_class "Notepad" is active
RButton:: ;this hotkey is only enabled while the above statement is true
WinMaximize ;maximize the active window
Send, Some text.{Enter} ;send some keyboard input
Return ;end of the hotkey
#If ;end of the special "#If" statement
正确的缩进对理解代码有很大帮助。
我正在尝试使用一个简单的脚本,该脚本仅在活动 window 打开并且您处于该 window 时才有效(例如某些 windowed 模式游戏)。所以脚本可以工作,但它也可以在活动 window 之外工作,例如在桌面或浏览器上。我不需要那个。我只需要它在我设置的活动 window 中工作。
脚本:
RButton::rightMouseClick()
rightMouseClick(){
if WinActive("ahk_class Notepad") {
WinMaximize
Send, Some text.{Enter}
return
}
}
因此,当您转到记事本并右键单击时,此示例有效。但是现在右键单击在计算机上的其他任何地方都不起作用?只有按住 shift 才有效?!
如何使此脚本 react/work/run 仅当活动 window 是记事本时?并且不在全球范围内工作。
#IfWinActive ahk_class Notepad
RButton::
WinMaximize
Send, Some text.{Enter}
Return
#If
这是我的建议:
#If WinActive("ahk_class Notepad") ;if the window with the ahk_class "Notepad" is active
RButton:: ;this hotkey is only enabled while the above statement is true
WinMaximize ;maximize the active window
Send, Some text.{Enter} ;send some keyboard input
Return ;end of the hotkey
#If ;end of the special "#If" statement
正确的缩进对理解代码有很大帮助。