【发布时间】:2022-11-10 01:55:25
【问题描述】:
我正在练习我的 AutoHotkey 技能,似乎遇到了一些问题。
我特别想尝试并学习如何创建一个制作 GUI,但现在我正在尝试制作一种显示和隐藏 GUI 窗口的方法。 我到目前为止的代码是:
; redundant variables for clarity
showConfig := true
hotkeyNew1 := ""
hotkeyNew2 := ""
; prompt for the hotkeys
Gui, New, , Config
Gui, Add, Text, x10 y10, Enter a hotkey for MsgBox1
Gui, Add, Hotkey, x+0 vhotkeyNew1, %vhotkeyNew1%
Gui, Add, Text, x10 y+0, Enter a hotkey for MsgBox2
Gui, Add, Hotkey, x+0 vhotkeyNew2, %vhotkeyNew2%
Gui, Add, Button, x10 y+0 w100 gSendHotkeys, Set Hotkeys
Gui, Show, hide w200 h100 Center, Config ; I assume this initializes the GUI? Either way, it doesn't seem to change anything if I omit it
!+s::
/*
; Note that this was my first attempt, but it yeilded a blank GUI
Gui, Show, % (showConfig ? "" : "hide") . " w200 h100", Config
*/
; This was my second attempt, also yielding a blank GUI
if (showConfig) {
Gui, Config:Show, w200 h100 Center, Config
} else {
Gui, Config:Hide
}
showConfig := !showConfig
return
SendHotkeys:
Hotkey, %hotkeyNew1%, hotkey1
Hotkey, %hotkeyNew2%, hotkey2
return
hotkey1:
MsgBox, Hotkey1
return
hotkey2:
MsgBox, Hotkey2
return
#+e:: ExitApp
有没有办法用热键隐藏和取消隐藏 GUI?我似乎无法让它工作。如果有帮助,我正在编写脚本然后编译它。
【问题讨论】: