Jump to content

Recommended Posts

Posted

Hi all. I am new to Autoit and learning quickly how powerful it is as a simple exe builder. However, I have a question that I cannot find a good answer or example for, so I am hoping to get some help on here directly.

I am attempting to build a multi-step gui that will take the user through a workflow process. I have already coded the first handfull of steps into a an AutoIT program using two separate GUI interfaces. In my code I have a function that builds GUI2() and I nest this function call within the "OK" button of the first GUI. This works fine for this short process, but I will need to go through 20+ steps and am enviosining an installer type program that will step through a process without recreating the GUI at each step.

Now I have this (simplifying the internals to just show my probelm):

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Dialog", 372, 331, 262, 148)

;Commands to build GUI from Koda

#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    ;Two buttons OK and CANCEL
     Case $Button2
            exit
        Case $GUI_EVENT_CLOSE
            Exit       
         Case $Button1
            ;Button 1 "OK" triggers some set of actions and builds GUI2()
            
            
            ;Remove GUI1
            GUIDelete($form1)
            
            ;Create GUI2 using a defined function
            GUI2()
            
            ;Listen for new interface still OK and CANCEL
            While 1
                $nMsg = GUIGetMsg()
                Switch $nMsg
                    Case $GUI_EVENT_CLOSE
                        Exit
                 Case $Button2
                        Exit
                        
                     Case $Button1
                        ;Perform some actions
                                                        
                        MsgBox(0,"Output","Set and Batch files generated")
                        Exit
                EndSwitch
            WEnd                        
    EndSwitch
WEnd

I am pretty sure I could build the whole process just continuing to nest the GUIs (e.g. place a GUI3 function under the GUI2 button structure), however this seems inelegant and difficult to manage over a multistep process. I believe this can be done fairly elegantly with GUICtrlUpdate functions but I am not sure how to define the new cases at each step without simply nesting all of the case commands. The code I would like to have is something like this:

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Dialog", 372, 331, 262, 148)

;Commands to build GUI from Koda

#EndRegion ### END Koda GUI section ###

;GUI 1 case structure
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    ;Two buttons OK and CANCEL
     Case $Button2
            exit
        Case $GUI_EVENT_CLOSE
            Exit       
         Case $Button1
            ;Button 1 "OK" triggers some set of actions
            
            ;Redraw GUI using GUICtrlUpdate
            
            ;Break out of this case structure and use a second loop below
               
    EndSwitch
WEnd

;GUI 2 case structure
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    ;Two buttons OK and CANCEL
     Case $Button2
            exit
        Case $GUI_EVENT_CLOSE
            Exit       
         Case $Button1
            ;Button 1 "OK" triggers some set of actions
            
            ;Redraw GUI using GUICtrlUpdate
            
            ;Break out of this case structure and use a second loop below
               
    EndSwitch
WEnd

Does anyone have a relevant example they could share of a GUI that steps through a lengthy process?

Thanks in advance.

-Pete

Posted

Or you could have a look at Tabs. My script is a good example how to create tabs with different controls and how to process the data entered into the tab.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

  • Moderators
Posted

PeteSeymour,

Welcome to the AutoIt forum. :)

I would create all the GUIs at the start of the script and then SHOW/HIDE them as necessary. That way you can code each GUI just as you want and very easily cycle through/back without difficulty. ;)

Are you happy to go with that or do you need any more advice? :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

You can also look at using tabs.

This example uses 10 tabs using native AutoIt code.

#include <GUIConstantsEx.au3>
#include <GUITab.au3>

Example()

Func Example()
    Local $aArray[11] = [10], $iHeight = 500, $iIndex = 0, $iWidth = 500
    Local $hGUI = GUICreate('', $iWidth, $iHeight)

    Local $iBack = GUICtrlCreateButton('Back', $iWidth - 180, $iHeight - 30, 85, 25)
    Local $iNext = GUICtrlCreateButton('Next', $iWidth - 90, $iHeight - 30, 85, 25)

    Local $iTab = GUICtrlCreateTab(-99, -99, 0, 0) ; Create a Tab group.
    For $i = 1 To $aArray[0]
        $aArray[$i] = GUICtrlCreateTabItem($i)
        GUICtrlCreateLabel('Page ' & $i, 10, 10)
    Next
    GUICtrlCreateTabItem('') ; Close the Tab group.

    _Toggle_EnableOrDisable($iBack, 0) ; Disable the back button.

    GUISetState(@SW_SHOW, $hGUI)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

            Case $iBack
                If $iIndex = ($aArray[0] - 1) Then ; Enabled the next button if the index is currently at the maximum number of tabs minus 1.
                    _Toggle_EnableOrDisable($iNext, 1) ; Enable the next button.
                EndIf

                $iIndex -= 1 ; Decrease the item index.
                If $iIndex <= 0 Then ; Disable the back button if the index is less than the number of tab items.
                    $iIndex = 0
                    _Toggle_EnableOrDisable($iBack, 0) ; Disable the back button.
                EndIf
                _GUICtrlTab_SetCurFocus($iTab, $iIndex)

            Case $iNext
                $iIndex += 1 ; Increase the item index.
                If $iIndex = 1 Then
                    _Toggle_EnableOrDisable($iBack, 1) ; Enable the back button if the index is equal to 1.
                EndIf

                If $iIndex >= ($aArray[0] - 1) Then ; Disable the next button if the index is greater than the number of tab items minus 1.
                    $iIndex = ($aArray[0] - 1)
                    _Toggle_EnableOrDisable($iNext, 0) ; Disable the next button.
                EndIf
                _GUICtrlTab_SetCurFocus($iTab, $iIndex)

        EndSwitch
    WEnd
EndFunc   ;==>Example

Func _Toggle_EnableOrDisable($iControlID, $iOverride = -1) ; By guinness.
    Local $aState[2] = [$GUI_ENABLE, $GUI_DISABLE]
    If $iOverride > -1 Then
        $iOverride = Number(Not $iOverride)
    Else
        $iOverride = Number(BitAND(GUICtrlGetState($iControlID), $aState[0]) = $aState[0])
    EndIf
    GUICtrlSetState($iControlID, $aState[$iOverride])
EndFunc   ;==>_Toggle_EnableOrDisable

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 parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Posted

Thank you for the quick responses. Guiness the code you have posted is exactly what I am looking to do. I appreciate the help.

You're welcome. You understand the code right? Because I didn't add many comments explaining what was happening.

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 parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

  • 4 months later...
Posted

You can also look at using tabs.

This example uses 10 tabs using native AutoIt code.

#include <GUIConstantsEx.au3>
#include <GUITab.au3>

Example()

Func Example()
    Local $aArray[11] = [10], $iHeight = 500, $iIndex = 0, $iWidth = 500
    Local $hGUI = GUICreate('', $iWidth, $iHeight)

    Local $iBack = GUICtrlCreateButton('Back', $iWidth - 180, $iHeight - 30, 85, 25)
    Local $iNext = GUICtrlCreateButton('Next', $iWidth - 90, $iHeight - 30, 85, 25)

    Local $iTab = GUICtrlCreateTab(-99, -99, 0, 0) ; Create a Tab group.
    For $i = 1 To $aArray[0]
        $aArray[$i] = GUICtrlCreateTabItem($i)
        GUICtrlCreateLabel('Page ' & $i, 10, 10)
    Next
    GUICtrlCreateTabItem('') ; Close the Tab group.

    _Toggle_EnableOrDisable($iBack, 0) ; Disable the back button.

    GUISetState(@SW_SHOW, $hGUI)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

            Case $iBack
                If $iIndex = ($aArray[0] - 1) Then ; Enabled the next button if the index is currently at the maximum number of tabs minus 1.
                    _Toggle_EnableOrDisable($iNext, 1) ; Enable the next button.
                EndIf

                $iIndex -= 1 ; Decrease the item index.
                If $iIndex <= 0 Then ; Disable the back button if the index is less than the number of tab items.
                    $iIndex = 0
                    _Toggle_EnableOrDisable($iBack, 0) ; Disable the back button.
                EndIf
                _GUICtrlTab_SetCurFocus($iTab, $iIndex)

            Case $iNext
                $iIndex += 1 ; Increase the item index.
                If $iIndex = 1 Then
                    _Toggle_EnableOrDisable($iBack, 1) ; Enable the back button if the index is equal to 1.
                EndIf

                If $iIndex >= ($aArray[0] - 1) Then ; Disable the next button if the index is greater than the number of tab items minus 1.
                    $iIndex = ($aArray[0] - 1)
                    _Toggle_EnableOrDisable($iNext, 0) ; Disable the next button.
                EndIf
                _GUICtrlTab_SetCurFocus($iTab, $iIndex)

        EndSwitch
    WEnd
EndFunc   ;==>Example

Func _Toggle_EnableOrDisable($iControlID, $iOverride = -1) ; By guinness.
    Local $aState[2] = [$GUI_ENABLE, $GUI_DISABLE]
    If $iOverride > -1 Then
        $iOverride = Number(Not $iOverride)
    Else
        $iOverride = Number(BitAND(GUICtrlGetState($iControlID), $aState[0]) = $aState[0])
    EndIf
    GUICtrlSetState($iControlID, $aState[$iOverride])
EndFunc   ;==>_Toggle_EnableOrDisable

Very nice StepGui, but i have a question:  Where do i put the contents of each page?

 

Oh, my God. They found me. I don't know how, but they found me. Run for it, Marty!

Posted

here:

For $i = 1 To $aArray[0]
    $aArray[$i] = GUICtrlCreateTabItem($i)
    GUICtrlCreateLabel('Page ' & $i, 10, 10)
Next
This code creates $aArray[0] tabitems, replace it with your tab contents.

GUICtrlCreateTabItem("mytab1")
GUICtrlCreateLabel( ...
 
GUICtrlCrateTabItem("mytab2")
...

Br, FireFox.

Thank you m8, ill let you know if i can make it work:)

Oh, my God. They found me. I don't know how, but they found me. Run for it, Marty!

Posted

What FireFox said. It's just an example and the loop was to create many tabs quickly.

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 parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Posted

Thank you m8, ill let you know if i can make it work:)

It works perfectly. Thank you very much guys. :thumbsup:

Oh, my God. They found me. I don't know how, but they found me. Run for it, Marty!

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...