Hypnotik Posted February 22, 2014 Posted February 22, 2014 Hi. I used search function and readed so much topics but i didn't understand yet how to assing a function to a GUIed button. I didn't understand how that Switch and Select work. Could someone make me an example assigning a function to a button ?
FireFox Posted February 22, 2014 Posted February 22, 2014 Hi, Take a look at the helpfile (F1 in SciTE) for the GUIGetMsg or GUICtrlSetOnEvent function. Br, FireFox. Danyfirex 1
Hypnotik Posted February 22, 2014 Author Posted February 22, 2014 I have read this already but i surely be wrong on something. I didn't understand how it works Local $iMsg = 0 While 1 $iMsg = GUIGetMsg() Select Case $Button1 MsgBox($MB_SYSTEMMODAL, "Test", "Test") ExitLoop EndSelect WEnd
FireFox Posted February 22, 2014 Posted February 22, 2014 (edited) It's a Switch statement you need, not a Select. Switch $iMsg Case $Button1 ... ;Or (but not recommended) Select Case $iMsg = $Button1 ... _ Br, FireFox. Edited February 22, 2014 by FireFox
Hypnotik Posted February 22, 2014 Author Posted February 22, 2014 (edited) Switch Case $Button1 $msgbox = MsgBox(0,"Msg","Test") EndSwitch This didn't work too Edited February 22, 2014 by Hypnotik
FireFox Posted February 22, 2014 Posted February 22, 2014 Switch $iMsg There's a variable to compare with Case statements. Take a look at the helpfile you will find all informations you need, it seems like you're not applying carrefuly the examples. Br, FireFox.
Hypnotik Posted February 22, 2014 Author Posted February 22, 2014 It's not that i didn't apply it,it's that i didn't understand what to do with them I used also that variable but i didn't work neither What about making a pratic example? Something stupid just like showing up a msgbox after pressing a button And about the help file, in my personal mind i think that the 60% of the examples there are just confusing for newbies like me.
Solution FireFox Posted February 22, 2014 Solution Posted February 22, 2014 There are examples everywhere, even in the helpfile. I don't get it. Anyway : #include <GUIConstantsEx.au3> GUICreate("MyGUI") $iButton1 = GUICtrlCreateButton("Button1", 20, 20, 80, 22) GUISetState(@SW_SHOW) Local $iMsg = 0 While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE ExitLoop Case $iButton1 MsgBox(0, "", "Button1 clicked") EndSwitch WEnd Br, FireFox.
scila1996 Posted February 22, 2014 Posted February 22, 2014 First you draw a GUIDE ago by koda '?do=embed' frameborder='0' data-embedContent>> Then we will handle: D A simple example #include <GUIConstantsEx.au3> Opt("GUIOnEventMode",1) ; Enable GUI Event Mode with 1 ; Start Create GUI $hGUI = GUICreate("Example",500,500,-1,-1) $But = GUICtrlCreateButton("Click",100,100,100,100) GUISetState() ; Show GUI ;Set Event Click GUISetOnEvent($GUI_EVENT_CLOSE,"Exit1") ; If you press the X button ---> Call Function Exit1 GUICtrlSetOnEvent($But,"Notepad") ; If Click to Button ---> Call Function Note Func Notepad() Run("notepad.exe") EndFunc Func Exit1() Exit EndFunc ; mandatory While 1 Sleep(10) WEnd
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