Polls the GUI to see if any events have occurred.
GUIGetMsg ( [advanced = 0] )
advanced | [optional] return extended information in an array. $GUI_EVENT_SINGLE (0) = (default) Returns a single event. $GUI_EVENT_ARRAY (1) = returns an array containing the event and extended information. Constants are defined in GUIConstantsEx.au3. |
Event ID: | the ID of the control sending the message |
$GUI_EVENT_NONE (0): | No event |
$GUI_EVENT_CLOSE: | dialog box being closed (either by defined button or system menu). |
$GUI_EVENT_MINIMIZE: | dialog box minimized with Windows title bar button. |
$GUI_EVENT_RESTORE: | dialog box restored by click on task bar icon. |
$GUI_EVENT_MAXIMIZE: | dialog box maximized with Windows title bar button. |
$GUI_EVENT_MOUSEMOVE: | the mouse cursor has moved. |
$GUI_EVENT_PRIMARYDOWN: | the primary mouse button was pressed. |
$GUI_EVENT_PRIMARYUP: | the primary mouse button was released. |
$GUI_EVENT_SECONDARYDOWN: | the secondary mouse button was pressed. |
$GUI_EVENT_SECONDARYUP: | the secondary mouse button was released. |
$GUI_EVENT_RESIZED: | dialog box has been resized. |
$GUI_EVENT_DROPPED: | End of a Drag&Drop action @GUI_DragId, @GUI_DragFile and @GUI_DropId will be used to retrieve the ID's/file corresponding to the involve control. |
This function automatically idles the CPU when required so that it can be safely used in tight loops without hogging all the CPU.
Information about the mouse position and the hovering control can be retrieved with GUIGetCursorInfo(). No event is fired when the mouse is over a control so GUIGetCursorInfo() must be called to retrieve the controlID.
GUICreate, GUICtrlCreate..., GUICtrlRead, GUICtrlSendMsg, GUICtrlSetOnEvent, GUIEventOptions (Option), GUIGetCursorInfo, GUIOnEventMode (Option)
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
Example()
; -------------------------------------------------------------------------------------
; Example - Press the button to see the value of the radio boxes
; The script also detects state changes (closed/minimized/timeouts, etc).
Func Example()
Opt("GUICoordMode", 1)
GUICreate("Radio Box Demo", 400, 280)
; Create the controls
Local $idButton_1 = GUICtrlCreateButton("B&utton 1", 30, 20, 120, 40)
GUICtrlCreateGroup("Group 1", 30, 90, 165, 160)
GUIStartGroup()
Local $idRadio_1 = GUICtrlCreateRadio("Radio &0", 50, 120, 70, 20)
GUICtrlCreateRadio("Radio &1", 50, 150, 60, 20)
Local $idRadio_3 = GUICtrlCreateRadio("Radio &2", 50, 180, 60, 20)
; Init our vars that we will use to keep track of GUI events
Local $iRadioVal1 = 0 ; We will assume 0 = first radio button selected, 2 = last button
; Show the GUI
GUISetState(@SW_SHOW)
Local $idMsg = 0
; In this message loop we use variables to keep track of changes to the radios, another
; way would be to use GUICtrlRead() at the end to read in the state of each control
While 1
$idMsg = GUIGetMsg()
Select
Case $idMsg = $GUI_EVENT_CLOSE
MsgBox($MB_SYSTEMMODAL, "", "Dialog was closed")
ExitLoop
Case $idMsg = $GUI_EVENT_MINIMIZE
MsgBox($MB_SYSTEMMODAL, "", "Dialog minimized", 2)
Case $idMsg = $GUI_EVENT_RESTORE
MsgBox($MB_SYSTEMMODAL, "", "Dialog restored", 2)
Case $idMsg = $idButton_1
MsgBox($MB_SYSTEMMODAL, "", "Default button clicked:" & @CRLF & "Radio " & $iRadioVal1)
Case $idMsg >= $idRadio_1 And $idMsg <= $idRadio_3
$iRadioVal1 = $idMsg - $idRadio_1
EndSelect
WEnd
GUIDelete()
EndFunc ;==>Example
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
Example()
Func Example()
; Create a GUI.
Local $hGUI1 = GUICreate("Example GUI1")
; Create a button.
Local $idButton1 = GUICtrlCreateButton("Button1", 10, 10, 80, 22)
; Display the GUI
GUISetState(@SW_SHOW, $hGUI1)
; Create a GUI.
Local $hGUI2 = GUICreate("Example GUI2", 300, 300)
; Create a button.
Local $idButton2 = GUICtrlCreateButton("Button2", 10, 10, 80, 22)
; Display the GUI
GUISetState(@SW_SHOW, $hGUI2)
; Initialize a Local variable.
Local $aMsg = 0
While 1
; Assign to $aMsg the advanced GUI messages.
$aMsg = GUIGetMsg($GUI_EVENT_ARRAY)
; Switch from GUIs
Switch $aMsg[1]
Case $hGUI1
; The event comes from the GUI1
; Switch from event ID
Switch $aMsg[0]
Case $GUI_EVENT_CLOSE
ExitLoop
Case $idButton1
MsgBox($MB_SYSTEMMODAL, "", "Button1 clicked.")
EndSwitch
Case $hGUI2
; The event comes from the GUI2
; Switch from event ID
Switch $aMsg[0]
Case $GUI_EVENT_CLOSE
GUIDelete($hGUI2)
Case $idButton2
MsgBox($MB_SYSTEMMODAL, "", "Button2 clicked.")
EndSwitch
EndSwitch
WEnd
; Delete the previous GUIs and all controls.
GUIDelete($hGUI1)
EndFunc ;==>Example