Sign in to follow this  
Followers 0
Person2334

When a button is pressed a function starts

4 posts in this topic

I have been looking around and i just cant figure out how to make a function run when a button is pushed. Can someone please help me?

Share this post


Link to post
Share on other sites



I have been looking around and i just cant figure out how to make a function run when a button is pushed. Can someone please help me?

Hi Person2334,

The helpfile has a lot of good info on GUI creation. Here's an example of what you're talking about:

#include <ButtonConstants.au3>   ;included by Koda for GUI
#include <GUIConstantsEx.au3>   ;included by Koda for GUI
#include <WindowsConstants.au3>   ;included by Koda for GUI
Opt("GUIOnEventMode", 1)    ;set to on event mode
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 247, 113, 192, 124)  ;create GUI
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")    ;set event for user clicking red X
$btn_ClickMe = GUICtrlCreateButton("Click Me", 8, 16, 185, 57) ;create the button
GUICtrlSetOnEvent(-1, "Button1Click")      ;set event for clicking the button
GUISetState(@SW_SHOW)          ;show GUI
#EndRegion ### END Koda GUI section ###
While 1
Sleep(100)           ;loop around waiting for event
WEnd
Func Button1Click()         ;function called if button clicked see line 11
msgbox(1,"BUTTON CLICKED", "You clicked the click me button")
EndFunc
Func Form1Close()
Exit
EndFunc

Share this post


Link to post
Share on other sites

thanks, but when i try to do that with multiple buttons, and other gui items i just cant get it to work.

Share this post


Link to post
Share on other sites

ohps never mind i figured it out thanks!

Share this post


Link to post
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
Sign in to follow this  
Followers 0