1 | #include <GUIConstantsEx.au3> |
---|
2 | |
---|
3 | Opt("GUIOnEventMode", 1) ; Change to OnEvent mode |
---|
4 | $mainwindow = GUICreate("Hello World", 200, 100) |
---|
5 | GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") |
---|
6 | GUICtrlCreateLabel("Hello world! How are you?", 30, 10) |
---|
7 | $okbutton = GUICtrlCreateButton("OK", 70, 50, 60) |
---|
8 | GUICtrlSetOnEvent($okbutton, "OKButton") |
---|
9 | GUISetState(@SW_SHOW) |
---|
10 | |
---|
11 | While 1 |
---|
12 | Sleep(1000) ; Idle around |
---|
13 | WEnd |
---|
14 | |
---|
15 | Func OKButton() |
---|
16 | ;Note: at this point @GUI_CTRLID would equal $okbutton, |
---|
17 | ;and @GUI_WINHANDLE would equal $mainwindow |
---|
18 | MsgBox(0, "GUI Event", "You pressed OK!") |
---|
19 | EndFunc |
---|
20 | |
---|
21 | Func CLOSEClicked() |
---|
22 | ;Note: at this point @GUI_CTRLID would equal $GUI_EVENT_CLOSE, |
---|
23 | ;and @GUI_WINHANDLE would equal $mainwindow |
---|
24 | MsgBox(0, "GUI Event", "You clicked CLOSE! Exiting...") |
---|
25 | Exit |
---|
26 | EndFunc |
---|