swstrau118 Posted December 11, 2013 Posted December 11, 2013 I have coded a GUI with 16 buttons, I am just using individual functions to call each button when pressed it calls a batch file - is there a better way of coding? Also I am trying to code in a MSGBOX when the button is pressed it asks them if they want to proceed (YES or NO) - how can I code the if statement if they press not to not close the GUI but to let them go back to the GUI to press another button? Here is my code: Thanks! Func All() $Result = MsgBox(4, "blaj","ndejded") If $Result = 6 Then Run("Auto.bat") Else exit EndIf EndFunc
l3ill Posted December 11, 2013 Posted December 11, 2013 I have coded a GUI with 16 buttons, I am just using individual functions to call each button when pressed it calls a batch file - is there a better way of coding? Switch Case EndSwitch Also I am trying to code in a MSGBOX when the button is pressed it asks them if they want to proceed (YES or NO) - how can I code the if statement if they press not to not close the GUI but to let them go back to the GUI to press another button? Here is my code: Example: #include <Inet.au3> Local $PublicIP = _GetIP() $iMsgBoxAnswer = MsgBox(1, "IP Address", "Your IP Address is: " & $PublicIP & @CRLF & "Copy to Clipboard?") Select Case $iMsgBoxAnswer = 1 ;OK ClipPut ($PublicIP) Case $iMsgBoxAnswer = 2 ;Cancel EndSelect Bill My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example
kylomas Posted December 11, 2013 Posted December 11, 2013 (edited) swstrau118, Here's one way... expandcollapse popup#include <ButtonConstants.au3> #include <Constants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <GuiButton.au3> #include <array.au3> #AutoIt3Wrapper_Add_Constants=n local $gui010 = guicreate('') local $aSize = wingetclientsize($gui010) local $lbl010 = guictrlcreatelabel('Some meaningful text',0,20,$aSize[0],20,bitor($ss_sunken, $SS_CENTER)) local $aButtons[16], $idx = 0 for $1 = 1 to 4 for $2 = 1 to 4 $aButtons[$idx] = guictrlcreatebutton('#' & $idx+1,$2*55,$1*55,35,35) $idx += 1 Next next guisetstate() while 1 switch guigetmsg() case $gui_event_close Exit case $aButtons[0] to $aButtons[ubound($aButtons)-1] for $1 = 0 to ubound($aButtons) - 1 if bitand(_GUICtrlButton_GetState($aButtons[$1]),$BST_FOCUS) = $BST_FOCUS then _Button_action($1+1) next EndSwitch WEnd func _Button_action($button_number) switch msgbox($MB_OKCANCEL,'','Button Pushed = ' & $button_number & @LF) case 1 ConsoleWrite('Doing something with button #' & $button_number & @LF) return case 2 ConsoleWrite('Returning without doing anything with button #' & $button_number & @LF) Return endswitch endfunc kylomas edit: corrected return placement Edited December 11, 2013 by kylomas Wombat 1 Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill
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