RegularGuy Posted March 15, 2012 Posted March 15, 2012 (edited) I have been trying to figure out the best way (practice) of preforming this task. I am still new to this all (auto it as well as programming) and I need some help. I'm creating a wizard that prompts the user for several peices of information and then returns an answer. I have included this sample code of the method that I've begun using but I would like some feedback as to what I could do differently, because I know there is a better way that what I have here. expandcollapse popupGlobal $GuiHeight = 400 Global $GuiWidth = 350 Global $ButtonWidth1 = 100 GLobal $NavButton = 75 Global $Centered = $GuiWidth/2-$ButtonWidth1/2 Global $NavCentered = $GuiWidth/2-$NavButton/2 GLobal $Left = 10 Global $Bottom = $GuiHeight-25-$Left Global $Right = $GuiWidth-$NavButton-$Left _Inception() Func _Inception() Local $GuiDescription = "You're getting sleepy" GUICreate("",$GuiWidth,$GuiHeight) GUICtrlCreateLabel($GuiDescription,$Left,10) Local $cancel = GUICtrlCreateButton("Cancel", $Left, $Bottom,$NavButton) local $next = GUICtrlCreateButton("Next", $Right, $Bottom, $NavButton) GUICtrlCreateLabel("Level 1",$GuiWidth/2,$GuiHeight/2) GUISetState() While 1 Local $msg = GUIGetMsg() Switch $msg Case -3 Exit Case $cancel Exit Case $next GUIDelete() _Inception2() EndSwitch WEnd EndFunc Func _Inception2() Local $GuiDescription = "Follow the White Rabbit." GUICreate("",$GuiWidth,$GuiHeight) GUICtrlCreateLabel($GuiDescription,$Left,10) Local $cancel = GUICtrlCreateButton("Cancel", $Left, $Bottom,$NavButton) Local $back = GUICtrlCreateButton("Back", $NavCentered,$Bottom,$NavButton) local $next = GUICtrlCreateButton("Next", $Right, $Bottom, $NavButton) GUICtrlCreateLabel("Level 2",$GuiWidth/2,$GuiHeight/2) local $Button1 = Guictrlcreatebutton("Test 1",$Left,40,100) local $Button2 = Guictrlcreatebutton("Test 2",$Centered,40,100) local $Button3 = Guictrlcreatebutton("Test 3",$Right-25,40,100) GUISetState() While 1 Local $msg = GUIGetMsg() Switch $msg Case -3 Exit Case $cancel Exit Case $back GUIDelete() _Inception() Case $next GUIDelete() _Inception3() EndSwitch WEnd EndFunc Func _Inception3() Local $GuiDescription = "You are Fast asleep" GUICreate("",$GuiWidth,$GuiHeight) GUICtrlCreateLabel($GuiDescription,$Left,10) Local $cancel = GUICtrlCreateButton("Cancel", $Left, $Bottom,$NavButton) Local $back = GUICtrlCreateButton("Back", $NavCentered,$Bottom,$NavButton) GUICtrlCreateLabel("Level 3",$GuiWidth/2,$GuiHeight/2) local $Button1 = Guictrlcreatebutton("Test 1",$Left,100,100) local $Button2 = Guictrlcreatebutton("Test 2",$Centered,70,100) local $Button3 = Guictrlcreatebutton("Test 3",$Right-25,100,100) GUISetState() While 1 Local $msg = GUIGetMsg() Switch $msg Case -3 Exit Case $cancel Exit Case $back GUIDelete() _Inception2() EndSwitch WEnd EndFunc Again, I know there is a better way. Ideally, I liked what Valuater did in his Autoit 1-2-3 program where there was one window that changed as you hit next. I just don't know how to create something like that or, what I should even be looking for in order to study how to create that. Thank you in advance! EDIT> Edited code for clarity Edited March 15, 2012 by RegularGuy
ProgAndy Posted March 15, 2012 Posted March 15, 2012 What about something like this? expandcollapse popup#include<WindowsConstants.au3> Opt("GUIOnEventMode", 1) Global $hStepGUIS[3] $hGUI = GUICreate("MainGUI", 400, 400) GUISetOnEvent(-3, "_Main_Exit") $hStepGUIS[0] = GUICreate("Step1", 400, 370, 0, 0, $WS_CHILD, $WS_EX_CONTROLPARENT, $hGUI) GUICtrlCreateButton("&Next", 10, 10, 100, 100) GUICtrlSetOnEvent(-1, "Step1_Next") $hStepGUIS[1] = GUICreate("Step2", 400, 370, 0, 0, $WS_CHILD, $WS_EX_CONTROLPARENT, $hGUI) GUICtrlCreateButton("&Next", 200, 10, 100, 100) GUICtrlSetOnEvent(-1, "Step2_Next") $hStepGUIS[2] = GUICreate("Step3", 400, 370, 0, 0, $WS_CHILD, $WS_EX_CONTROLPARENT, $hGUI) GUICtrlCreateButton("&Back To Start", 200, 200, 100, 100) GUICtrlSetOnEvent(-1, "Step3_Next") SwitchToStep(0) GUISetState(@SW_SHOW, $hGUI) While 1 Sleep(100) WEnd Func Step1_Next() MsgBox(0, "", "Step1 Finished") SwitchToStep(1) EndFunc Func Step2_Next() MsgBox(0, "", "Step 2 stopped") SwitchToStep(2) EndFunc Func Step3_Next() MsgBox(0, "", "Go to beginning now") SwitchToStep(0) EndFunc Func SwitchToStep($step) Local $max = UBound($hStepGUIS) - 1 If $step < 0 Or $step > $max Then Return SetError(1, 0, 0) For $i = 0 To $max If $i = $step Then GUISetState(@SW_SHOW, $hStepGUIS[$i]) GUISwitch($hStepGUIS[$i]) Else GUISetState(@SW_HIDE, $hStepGUIS[$i]) EndIf Next Return 1 EndFunc Func _Main_Exit() Exit EndFunc *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes
RegularGuy Posted March 16, 2012 Author Posted March 16, 2012 Thank you for the post, sorry I didn't respond sooner. This is great for moving forward, could you please demonstrate how you would move backwards? ex. move from step 3 back to step two. Also, would you recommend this for a wizard that has like 50 different GUI's (or at least different input pages)? That is about the amount that I am looking at creating
guinness Posted March 16, 2012 Posted March 16, 2012 Are you sure an 'installer like application' is the best route to take? Even Windows doesn't have that amount of pages to install the operating system. UDF List:  _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
ProgAndy Posted March 16, 2012 Posted March 16, 2012 (edited) Thank you for the post, sorry I didn't respond sooner. This is great for moving forward, could you please demonstrate how you would move backwards? ex. move from step 3 back to step two.Also, would you recommend this for a wizard that has like 50 different GUI's (or at least different input pages)? That is about the amount that I am looking at creatingI showed only the next-Button, the Back-Button will be implemented the same way. Using SwitchToStep you can jump to any step you want.For a 50-Page GUI, I would recommend an additional TreeView on the left side where you can manually jump to the pagesPS: An example of what I mean from monodevelop: http://monodevelop.com/@api/deki/files/189/=OptionsDialogReorg.png Edited March 16, 2012 by ProgAndy RegularGuy 1 *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes
acidman Posted March 16, 2012 Posted March 16, 2012 (edited) The easiest way is to create a parent Gui and a bunch of child gui's, which in this case you just Hide and show them when moving to the next Child therefore you can just show Them again if you need to Go back The treeview idea was a good one, but instead of all that code Just use For the "next" Buttons Guisetstate($ChildGui1, @sw_hide) Guisetstate($ChildGui2, @sw_Show) And for The "Back Buttons" Guisetstate($ChildGui1, @sw_Show) Guisetstate($ChildGui2, @sw_Hide) This way you don't need to use all that code, plus its easier to understand. Edited March 16, 2012 by ac1dm4nner [u]My dream is to have a dream...[/u]
acidman Posted March 16, 2012 Posted March 16, 2012 The method I showed you when using a treeview you could aswell hide the current Child Gui And Jump to the selected Child Gui, best practises are often the ones we had to practice again and again. [u]My dream is to have a dream...[/u]
Moderators Melba23 Posted March 16, 2012 Moderators Posted March 16, 2012 ac1dm4nner,There is an "Edit" button on your posts - start using it please. M23  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Â
ProgAndy Posted March 16, 2012 Posted March 16, 2012 The easiest way is to create a parent Gui and a bunch of child gui's, which in this case you just Hide and show them when moving to the next Child therefore you can just show Them again if you need to Go back The treeview idea was a good one, but instead of all that code Just use For the "next" Buttons Guisetstate($ChildGui1, @sw_hide) Guisetstate($ChildGui2, @sw_Show) And for The "Back Buttons" Guisetstate($ChildGui1, @sw_Show) Guisetstate($ChildGui2, @sw_Hide) This way you don't need to use all that code, plus its easier to understand. That is exactly what my code is doing. I just manage the child GUIs in an array and use a function to switch between them. *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes
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