Jump to content

GUICtrlCreateButton to call a Function


 Share

Go to solution Solved by Andreik,

Recommended Posts

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!

Link to comment
Share on other sites

  • Solution
#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

 

When the words fail... music speaks.

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...