Function Reference

GUIGetMsg

Polls the GUI to see if any events have ocurred.

GUIGetMsg ( [advanced] )

 

Parameters

advanced [optional] return extended information in an array.
0 = (default) Returns a single event.
1 = returns an array containing the event and extended information.

 

Return Value

Returns an event, or an array depending on the "advanced" parameter.
The "event" returned is the control ID of the control sending the message, or it is a special event (like the window is closing, minimizing). Or if there is no message, the event is 0.


Event IDs
0 No event
Control ID the ID of the control sending the message
$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


When using the "advanced" parameter the information is returned in an array with extended information:
$array[0] = 0 or Event ID or Control ID
$array[1] = The window handle the event is from
$array[2] = The control handle the event is from (if applicable)
$array[3] = The current X position of the mouse cursor (relative to the GUI window)
$array[4] = The current Y position of the mouse cursor (relative to the GUI window)


If the GUIOnEventMode option is set to 1 then the return from GUIGetMsg is always 0 and the @error is set to 1.

 

Remarks

This function automatically idles the CPU when required so that it can be safely used in tight loops without hogging all the CPU.

 

Related

GUICreate, GUICtrlCreate..., GUICtrlRead, GUIOnEventMode (Option)

 

Example



;-------------------------------------------------------------------------------------
; Example - Press the button to see the value of the radio boxes
; The script also detects state changes (closed/minimized/timeouts, etc).

#include <GUIConstants.au3>

Opt("GUICoordMode", 1)
GUICreate("Radio Box Demo", 400,280)

; Create the controls
$button_1 = GUICtrlCreateButton ("B&utton 1", 30, 20, 120, 40)
$group_1 = GUICtrlCreateGroup ("Group 1", 30, 90, 165, 160)
GUIStartGroup()
$radio_1 = GUICtrlCreateRadio ("Radio &0", 50, 120, 70, 20)
$radio_2 = GUICtrlCreateRadio ("Radio &1", 50, 150, 60, 20)
$radio_3 = GUICtrlCreateRadio ("Radio &2", 50, 180, 60, 20)

; Init our vars that we will use to keep track of GUI events
$radioval1 = 0    ; We will assume 0 = first radio button selected, 2 = last button
$radioval2 = 2

; Show the GUI
GUISetState ()

; 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
   $msg = GUIGetMsg()
   Select
       Case $msg = $GUI_EVENT_CLOSE
         MsgBox(0, "", "Dialog was closed")
         Exit
      Case $msg = $GUI_EVENT_MINIMIZE
         MsgBox(0,"", "Dialog minimized",2)
      Case $msg = $GUI_EVENT_MAXIMIZE
         MsgBox(0,"", "Dialog restored",2)
   
      Case $msg = $button_1
         MsgBox(0, "Default button clicked", "Radio " & $radioval1 )
         
      Case $msg >= $radio_1 AND $msg <= $radio_3
         $radioval1 = $msg - $radio_1

   EndSelect
WEnd