Gui 用函式代替標籤
顯示如何使用函式而不是標籤建立 Guis 的示例。
Gui, Add, Button, gCtrlEvent vButton1, Button 1
Gui, Add, Button, gCtrlEvent vButton2, Button 2
Gui, Add, Button, gGoButton, Go Button
Gui, Add, Edit, vEditField, Example text
Gui, Show,, Functions instead of labels
CtrlEvent(CtrlHwnd:=0, GuiEvent:="", EventInfo:="", ErrLvl:="") {
GuiControlGet, controlName, Name, %CtrlHwnd%
MsgBox, %controlName% has been clicked!
}
GoButton(CtrlHwnd:=0, GuiEvent:="", EventInfo:="", ErrLvl:="") {
GuiControlGet, EditField
MsgBox, Go has been clicked! The content of the edit field is "%EditField%"!
}
GuiClose(hWnd) {
WinGetTitle, windowTitle, ahk_id %hWnd%
MsgBox, The Gui with title "%windowTitle%" has been closed!
ExitApp
}