Jump to content

Change


au3scr
 Share

Recommended Posts

I believe your asking about preforming an action from a gui. In the help file search for gui concepts. It will list message loop mode and Onevent mode. As follows. The help file has many more details.

message loop:

#include <GUIConstants.au3>

$mainwindow = GUICreate("Hello World", 200, 100)
GUICtrlCreateLabel("Hello world! How are you?", 30, 10)
$okbutton = GUICtrlCreateButton("OK", 70, 50, 60)

$dummywindow = GUICreate("Dummy window for testing ", 200, 100)

GUISwitch($mainwindow)
GUISetState(@SW_SHOW)

While 1
  $msg = GUIGetMsg(1)

  Select
    Case $msg[0] = $okbutton
      MsgBox(0, "GUI Event", "You pressed OK!")

    Case $msg[0] = $GUI_EVENT_CLOSE And $msg[1] = $mainwindow 
      MsgBox(0, "GUI Event", "You clicked CLOSE on the main window! Exiting...")
      ExitLoop
  EndSelect
WEndoÝ÷ ÚÞ½éíjëh×6#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)  ; Change to OnEvent mode 
$mainwindow = GUICreate("Hello World", 200, 100)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUICtrlCreateLabel("Hello world! How are you?", 30, 10)
$okbutton = GUICtrlCreateButton("OK", 70, 50, 60)
GUICtrlSetOnEvent($okbutton, "OKButton")
GUISetState(@SW_SHOW)

While 1
  Sleep(1000)  ; Idle around
WEnd

Func OKButton()
  ;Note: at this point @GUI_CTRLID would equal $okbutton,
  ;and @GUI_WINHANDLE would equal $mainwindow
  MsgBox(0, "GUI Event", "You pressed OK!")
EndFunc

Func CLOSEClicked()
  ;Note: at this point @GUI_CTRLID would equal $GUI_EVENT_CLOSE, 
  ;and @GUI_WINHANDLE would equal $mainwindow 
  MsgBox(0, "GUI Event", "You clicked CLOSE! Exiting...")
  Exit
EndFunc
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...