AutoHotkey 在 GuiClose 之后执行命令而不点击 X 按钮
AutoHotkey executing commands after GuiClose without hitting the X button
我的目标是利用所学制作一个GUI,用三个按钮打开相应的.ahk文件。到目前为止,使用我的代码它可以完美运行,直到我添加代码以在关闭 GUI 时关闭脚本。当我添加此代码时...
GuiClose:
ExitApp
return
到顶部,它使脚本在 运行 后立即自行关闭。但如果我按下 GUI 上的 X 按钮,我只希望那段代码为 运行。我在这里错过了什么?
我的所有代码:
#SingleInstance, force
GuiClose:
ExitApp
return
Gui, Add, Button, y0 x0 w32 h32 g1, 1
Gui, Add, Button, y0 x45 w32 h32 g2, 2
Gui, Add, Button, y0 x90 w32 h32 g3, 3
Gui, Show, x800 y50 w150 h100, The Gui
return
1:
run, open "C:\users\Milquetoast\Desktop\learned.ahk"
return
2:
run, open "C:\users\Milquetoast\Desktop\learned2.ahk"
return
3:
run, open "C:\users\Milquetoast\Desktop\learned3.ahk"
return
auto-exection section(=上面第一个热键、hotstring、return之前的脚本, OnMessage 或 GUI 定义)在脚本启动时自动执行。
因此您不能在此部分定义label(子程序)。
#SingleInstance, force
Gui, Add, Button, y0 x0 w32 h32 g1, 1
Gui, Add, Button, y0 x45 w32 h32 g2, 2
Gui, Add, Button, y0 x90 w32 h32 g3, 3
Gui, Show, x800 y50 w150 h100, The Gui
RETURN ; === end of auto-execute section ===
1:
run, C:\users\Milquetoast\Desktop\learned.ahk
return
2:
run, C:\users\Milquetoast\Desktop\learned2.ahk
return
3:
run, C:\users\Milquetoast\Desktop\learned3.ahk
return
GuiClose:
ExitApp
return
我的目标是利用所学制作一个GUI,用三个按钮打开相应的.ahk文件。到目前为止,使用我的代码它可以完美运行,直到我添加代码以在关闭 GUI 时关闭脚本。当我添加此代码时...
GuiClose:
ExitApp
return
到顶部,它使脚本在 运行 后立即自行关闭。但如果我按下 GUI 上的 X 按钮,我只希望那段代码为 运行。我在这里错过了什么?
我的所有代码:
#SingleInstance, force
GuiClose:
ExitApp
return
Gui, Add, Button, y0 x0 w32 h32 g1, 1
Gui, Add, Button, y0 x45 w32 h32 g2, 2
Gui, Add, Button, y0 x90 w32 h32 g3, 3
Gui, Show, x800 y50 w150 h100, The Gui
return
1:
run, open "C:\users\Milquetoast\Desktop\learned.ahk"
return
2:
run, open "C:\users\Milquetoast\Desktop\learned2.ahk"
return
3:
run, open "C:\users\Milquetoast\Desktop\learned3.ahk"
return
auto-exection section(=上面第一个热键、hotstring、return之前的脚本, OnMessage 或 GUI 定义)在脚本启动时自动执行。
因此您不能在此部分定义label(子程序)。
#SingleInstance, force
Gui, Add, Button, y0 x0 w32 h32 g1, 1
Gui, Add, Button, y0 x45 w32 h32 g2, 2
Gui, Add, Button, y0 x90 w32 h32 g3, 3
Gui, Show, x800 y50 w150 h100, The Gui
RETURN ; === end of auto-execute section ===
1:
run, C:\users\Milquetoast\Desktop\learned.ahk
return
2:
run, C:\users\Milquetoast\Desktop\learned2.ahk
return
3:
run, C:\users\Milquetoast\Desktop\learned3.ahk
return
GuiClose:
ExitApp
return