使用此代码:
Loop
{
WinWait, Untitled - Notepad
WinClose, Untitled - Notepad
}
我想自动关闭所有新的记事本窗口。
然后我想添加一个键盘快捷键来退出AHK脚本:
Esc::ExitApp
但是当我添加
Esc::ExitApp
时,循环似乎不起作用,并且在代码仍在运行时记事本窗口不会自动关闭:
Esc::ExitApp ; ==> this line is causing the loop to malfunction and not work as expected
Loop
{
WinWait, Untitled - Notepad
WinClose, Untitled - Notepad
}
为什么会发生这种情况以及如何使其按预期工作?!
return之后的未标记代码无法访问并且永远不会执行。
热键
Esc::ExitApp
是一个单行热键,具有隐含的返回值。
在这种情况下,您可以使用 If 语句来使循环工作:
Loop
{
If WinExist("Untitled - Notepad")
WinClose
If GetKeyState("Esc","P")
ExitApp
}
不幸的是,autohotkey 帮助网站目前已停止服务,因此我无法附加任何超链接。