Jump to content
Sign in to follow this  
Medryn

Best method to create sequential windows...

Recommended Posts

Medryn

I'm new to AutoIt & forums and I'm trying to make a program that works on the same concept as a Windows Installer in how it continues to provide windows of options through navigation using next & cancel buttons. I've played with some ideas in AutoIt but keep hitting dead ends. What is the most efficient way to code this? What I'd like to start with is 3 seperate windows sequentially. Window 1 shows, options selected, next > Window 2 shows, options selected, next > Windows 3 shows options selected, next > and so on... Thanks for the view!!

Medryn

Share this post


Link to post
Share on other sites
enaiman

Don't bother using separate windows - use tabs instead; the "Next" button will make the next tab to show.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 329, 297, 193, 125)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
$Tab1 = GUICtrlCreateTab(8, 8, 313, 281)
GUICtrlSetState($Tab1,$GUI_HIDE)            ;this is very important here
$TabSheet1 = GUICtrlCreateTabItem("TabSheet1")
GUICtrlSetState(-1,$GUI_SHOW)
$Button1 = GUICtrlCreateButton("Next", 232, 256, 75, 25, 0)
GUICtrlSetOnEvent(-1, "Button1Click")
$Label1 = GUICtrlCreateLabel("This is TAB 1", 88, 80, 156, 17, $SS_CENTER)
GUICtrlSetFont(-1, 9, 400, 0, "Tahoma")
$TabSheet2 = GUICtrlCreateTabItem("TabSheet2")
$Button2 = GUICtrlCreateButton("Previous", 16, 256, 75, 25, 0)
GUICtrlSetOnEvent(-1, "Button2Click")
$Button3 = GUICtrlCreateButton("Next", 232, 256, 75, 25, 0)
GUICtrlSetOnEvent(-1, "Button3Click")
$Label2 = GUICtrlCreateLabel("This is TAB 2", 90, 89, 156, 17, $SS_CENTER)
GUICtrlSetFont(-1, 9, 400, 0, "Tahoma")
$TabSheet3 = GUICtrlCreateTabItem("TabSheet3")
$Button4 = GUICtrlCreateButton("Previous", 16, 256, 75, 25, 0)
GUICtrlSetOnEvent(-1, "Button4Click")
$Label3 = GUICtrlCreateLabel("This is TAB 3", 79, 90, 156, 17, $SS_CENTER)
GUICtrlSetFont(-1, 9, 400, 0, "Tahoma")
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    Sleep(100)
WEnd

Func Button1Click()
    GUICtrlSetState($TabSheet2,$GUI_SHOW)
EndFunc
Func Button2Click()
    GUICtrlSetState($TabSheet1,$GUI_SHOW)
EndFunc
Func Button3Click()
    GUICtrlSetState($TabSheet3,$GUI_SHOW)
EndFunc
Func Button4Click()
    GUICtrlSetState($TabSheet2,$GUI_SHOW)
EndFunc
Func Form1Close()
    Exit
EndFunc

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites
Melba23

Medryn,

Here is a simple example with 3 GUIs created at the start and then shown/hidden as required:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Form1", 260, 200, 190, 120)
$Button11 = GUICtrlCreateButton("Next", 150, 100, 80, 30)
GUISetState(@SW_SHOW)

$Form2 = GUICreate("Form2", 260, 200, 290, 220)
$Button21 = GUICtrlCreateButton("Back", 150,  60, 80, 30)
$Button22 = GUICtrlCreateButton("Next", 150, 100, 80, 30)
GUISetState(@SW_HIDE)

$Form3 = GUICreate("Form3", 260, 200, 390, 320)
$Button31 = GUICtrlCreateButton("Back", 150,  60, 80, 30)
$Button32 = GUICtrlCreateButton("Exit", 150, 100, 80, 30)
GUISetState(@SW_HIDE)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button11
            _Form2()
    EndSwitch
WEnd

Func _Form2()
    
    GUISetState(@SW_HIDE, $Form1)
    GUISetState(@SW_SHOW, $Form2)
    
    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                Exit
            Case $Button21
                GUISetState(@SW_HIDE, $Form2)
                GUISetState(@SW_SHOW, $Form1)
                Return
            Case $Button22
                _Form3()
                Return
        EndSwitch
    WEnd    

EndFunc

Func _Form3()
    
    GUISetState(@SW_HIDE, $Form2)
    GUISetState(@SW_SHOW, $Form3)
    
    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE, $Button32
                Exit
            Case $Button31
                GUISetState(@SW_HIDE, $Form3)
                GUISetState(@SW_SHOW, $Form1)
                Return
        EndSwitch
    WEnd
    
EndFunc

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites
Medryn

M23: Thanks, thats perfect! Exactly what I was looking for. I see that my mistake was I wasn't understanding how to use Case within the While statements... you definately cleared it up for me.

Ena I really liked your alternate suggestion to, I can definately use this elsewhere, thanks a million!

AutoIt is great, but having such a good community and forum help is even better!

Medryn

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.