Person2334 0 Posted January 14, 2012 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
gruntydatsun 12 Posted January 15, 2012 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
Person2334 0 Posted January 15, 2012 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
Person2334 0 Posted January 15, 2012 ohps never mind i figured it out thanks! Share this post Link to post Share on other sites