Person2334 Posted January 14, 2012 Share 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? Link to comment Share on other sites More sharing options...
gruntydatsun Posted January 15, 2012 Share 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 Link to comment Share on other sites More sharing options...
Person2334 Posted January 15, 2012 Author Share 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. Link to comment Share on other sites More sharing options...
Person2334 Posted January 15, 2012 Author Share Posted January 15, 2012 ohps never mind i figured it out thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now