autohotkey - 关闭 GUI 但继续 AHK 中的脚本
问题描述
我正在尝试关闭 gui,但让脚本继续运行。esc
这是因为如果用户选择通过点击或简单地单击右上角的“X”来退出 GUI,我想执行其他操作。我不明白如何让脚本运行但关闭 gui。单击或 X 时,GUI 关闭似乎没有做任何事情esc
。我已经扫描了GUI文档,但无法弄清楚。他们总是运行exitapp,但我还没准备好exitapp,我需要做其他事情。
Gui, Add, Text, ,To cancel, press ESCAPE or close this window.
Gui, Show, w320 h80, Downloads
GuiClose:
GuiEscape:
; Continue on to do other things here!!!!
WinActivate ahk_exe notepad++.exe
; do things...
exitapp
解决方案
你所描述的听起来就像我想做的一样。这是很多艰难和零碎的工作,但我认为您正在寻找的是Gui, Cancel
看看下面的代码,看看这是否不能解决您的问题。
ExitApp
如果您想稍后弹出它,它不会使用并且不会破坏窗口。您必须弄清楚如何放置其余代码,但我相信这就是您要问的。
;Set the GUI window
Gui, Add, Text,, Hit Escape to Clear window when it is active
#F9:: ;show the window with WindowsKey-F9
Gui, Show,
return
;set the escape key to clear GUI window
GuiEscape: ; Note: single colon here, not double
Gui, Cancel
Return
如果您有多个 GUI 窗口,那就有点棘手了。您必须命名每个:
;Set the two GUI windows. In example, First is labeled as FirstGUI and second as SecondGUI. Notice how you separate with single colon.
Gui, FirstGUI:Add, Text,, Hit Escape to Clear FirstGUI window when it is active
Gui, SecondGUI:Add, Text,, Hit Escape to Clear SecondGUI window when it is active
#F9:: ;show the two windows ("xCenter y700" is used to prevent the windows from stacking.)
Gui, FirstGUI:Show, xCenter y700, Window Title of First GUI
Gui, SecondGUI:Show, xCenter y900, Window Title of Second GUI
return
;set the escape key to clear for each Gui independently.
FirstGUIGuiEscape: ; Note that you must add the Gui Name (FirstGUI) to the beginning of the "GuiEscape:" command and also name it in the following:
Gui, FirstGUI:Cancel
Return
SecondGUIGuiEscape: ; And here you must add SecondGUI as noted above.
Gui, SecondGUI:Cancel
Return
回答有点晚,但希望这对您或其他人有用!
推荐阅读
- c++ - 与传统头文件相比,c++20 中的模块会减少编译时间吗?
- python - 如何解决“无法从'figures'导入名称'plot_2d_separator'”错误?
- javascript - Vanilla JS 滑动功能现在覆盖链接/预期行为
- bash - 从从标准输入接收到的 shell 脚本中提取二进制有效负载
- keycloak - Keycloak - 请求用户通过 api 验证电子邮件地址
- android - Gradle - 无法初始化类 org.apache.http.conn.ssl.SSLConnectionSocketFactory
- c# - 如何将列表值映射到新对象属性
- javascript - 如何使用 React 钩子从数组中删除一个项目?
- python - 如何创建受密码保护的帖子页面
- javascript - 如何使用函数和 HTML 用户输入创建唯一对象