FlintBrenick Posted January 16, 2007 Share Posted January 16, 2007 This code is an example of a great way to structure your scripts. expandcollapse popup;Include #include <GUIConstants.au3>;Needed if you're going to have GUI in your script. ;Variables Dim $var1, $var2 = 123, $var3 = "Hello!" ;HotKey HotKeySet("d", "MyHotKeyFunc") ; GUI GUICreate("My GUI Window",250,250) ;Buttons $button1 = GUICtrlCreateButton("My Button 1",30,30,70,20) $button2 = GUICtrlCreateButton("My Button 2",30,60,70,20) $button3 = GUICtrlCreateButton("My Button 3",30,90,70,20) $button4 = GUICtrlCreateButton("Exit",30,120,70,20) ; GUI MESSAGE LOOP GuiSetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ;User clicked on the red 'X' on the window. The program will now end. Exit Case $msg = $button1 ;User clicked on 'My Button 1' msgbox(0,"$var1 Value", "$var1 = " & $var1) Something1() Case $msg = $button2 ;User clicked on 'My Button 2' msgbox(0,"$var2 Value", "$var2 = " & $var2) Something2() Case $msg = $button3 ;User clicked on 'My Button 3' msgbox(0,"$var3 Value", "$var3 = " & $var3) Something3() Case $msg = $button4 ;User click on 'My Button 4' Exit EndSelect WEnd ;Functions Func Something1() MsgBox(0,"Something1","The function 'Something1' was executed") EndFunc Func Something2() MsgBox(0,"Something1","The function 'Something2' was executed") EndFunc Func Something3() MsgBox(0,"Something1","The function 'Something3' was executed") EndFunc Func MyHotKeyFunc() MsgBox(0,"HotKey","You have pressed 'd' which is set as a Hot Key") EndFunc ;Exit Exit This program is very simple, however, I use this as a template for all programs I write. Enjoy! ~Bryan AKA Flint Brenick~ Link to comment Share on other sites More sharing options...
Valuater Posted January 16, 2007 Share Posted January 16, 2007 I try to teach one also( its in my sig ) 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