Jump to content

GUICtrlCreateButton to call a Function


Go to solution Solved by Andreik,

Recommended Posts

Posted

Good day,

Is there any way - again a neophyte here...to have this script employ/call a function?

; -----------------------------------------------
#include <AutoItConstants.au3>
#include <FontConstants.au3>
#include <GUIConstantsEx.au3>
; -----------------------------------------------
Local $hGUI=GUICreate("Title", 360, 215)
GUISetFont(12, $FW_BOLD, $GUI_FONTNORMAL, "Calibri")
Local $MyButton=GUICtrlCreateButton("Variable", 20, 20, 150, 25)
; -----------------------------------------------
GUISetState(@SW_SHOW, $hGUI)
; -----------------------------------------------
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $MyButton
            ExitLoop
    EndSwitch
WEnd
; -----------------------------------------------

Thanks!

  • Solution
Posted
#include <AutoItConstants.au3>
#include <FontConstants.au3>
#include <GUIConstantsEx.au3>
; -----------------------------------------------
Local $hGUI=GUICreate("Title", 360, 215)
GUISetFont(12, $FW_BOLD, $GUI_FONTNORMAL, "Calibri")
Local $MyButton=GUICtrlCreateButton("Variable", 20, 20, 150, 25)
; -----------------------------------------------
GUISetState(@SW_SHOW, $hGUI)
; -----------------------------------------------
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case  $MyButton
            MyFunc()
    EndSwitch
WEnd

Func MyFunc()
    MsgBox(0, '', 'Yayyy')
EndFunc

 

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
  • Recently Browsing   0 members

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