Jump to content

Multiple GUI confused


Recommended Posts

Hello everyone. I do apologize if this is the wrong area for this, but it doesn't have much to do with the GUI, mainly the code.

Here is my problem. I have 2 GUI's created in the same script, using functions. It works great, when I press a button, it opens up the next GUI. When I press a button in the new GUI, it opens a third GUI. The problem I am having is that when I open the second GUI, I need the first one to close. Here is what I have so far. For some reason, I can't seem to find any help in the help docs.

#cs ----------------------------------------------------------------------------

AutoIt Version: 3.3.8.1
Author: myName

Script Function:
Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

#include 
#include 
#include 
#include 

Global $msg, $mainMenu, $wButton, $mainMenu1, $Welcome, $Intro, $ES_CENTER, $ES_READONLY

Call ("intro1")

Call ("mainMenu1")

Call ("startHere1")

intro1()

Func intro1()
$Intro = GUICreate("Welcome", 472, 309, 192, 124)
$Label1 = GUICtrlCreateLabel("Welcome to the TruTops Programming Guide.", 45, 8, 400, 34, $SS_CENTER)
GUICtrlSetFont(-1, 20, 800, 2, "AriaScriptSSK")
$Label2 = GUICtrlCreateLabel("This guide was created to help the user in programming TruTops Mark.", 67, 56, 337, 17, $SS_CENTER)
$Label3 = GUICtrlCreateLabel("We will go through all of the steps of each programming option in the TruTops Mark Program itself.", 3, 72, 465, 17, $SS_CENTER)
$Label4 = GUICtrlCreateLabel("First, If you noticed, the door to the machine has already opened.", 80, 88, 310, 17, $SS_CENTER)
$Label5 = GUICtrlCreateLabel("Before we begin, please clear off anything that may be in the way of the table movement.", 24, 104, 422, 17, $SS_CENTER)
$Label6 = GUICtrlCreateLabel("Also, clear off the table with the acception of the A-Axis and the guide blocks that are in place.", 11, 120, 448, 17, $SS_CENTER)
$Label7 = GUICtrlCreateLabel("Once that is done, Please proceed and click OK", 119, 136, 232, 17, $SS_CENTER)
$Button1 = GUICtrlCreateButton("Continue", 104, 216, 75, 25)
$Button2 = GUICtrlCreateButton("Exit", 296, 216, 75, 25)
GUISetState()


While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
Exit
Case $msg = $Button2
Exit
Case $msg = $Button1
Call("mainMenu1")
Case $msg = $Button1
EndSelect
WEnd
EndFunc


mainMenu1()

Func mainMenu1()

$mainMenu = GUICreate("Main Menu", 320, 282, 193, 125, -1, -1, $Welcome)
$Label1 = GUICtrlCreateLabel("Please select a starting point below.", 73, 16, 173, 17)
$Label2 = GUICtrlCreateLabel("Each button will open a more in depth set of options.", 34, 48, 251, 17)
$startHere = GUICtrlCreateButton("Start Here", 122, 88, 75, 25)
$axisCommands = GUICtrlCreateButton("Axis Commands", 114, 120, 91, 25)
$markCommands = GUICtrlCreateButton("Mark Commands", 110, 152, 99, 25)
$systemCommands = GUICtrlCreateButton("System Commands", 110, 184, 99, 25)
$exit = GUICtrlCreateButton("Exit", 122, 216, 75, 25)
GUISetState()


While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
Exit
Case $msg = $exit
Call("intro1")
Case $msg = $startHere
Call("startHere1")
EndSelect
WEnd
EndFunc


startHere1()

Func startHere1()

$pgStartHere = GUICreate("Start Here", 566, 525, 192, 124)
$Edit1 = GUICtrlCreateEdit("", 32, 24, 489, 441, $ES_CENTER, $ES_READONLY)
GUICtrlSetData(-1, StringFormat("This is Text"), $ES_READONLY)
$_mainMenu = GUICtrlCreateButton("Main Menu", 120, 480, 75, 25)
$Exit = GUICtrlCreateButton("Exit", 360, 480, 75, 25)
GUISetState(@SW_SHOW)


While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
Exit
Case $msg = $Exit
Exit
Case $msg = $_mainMenu
GUISwitch($mainMenu)
EndSelect
WEnd
EndFunc

Before I go. I'm not looking for an easy way out. I am looking for a more complicated way of doing this because I learn better when it makes me think. I believe that when I figure this out I will be able to complete more projects.

Thank you in advance.

Skorpius

Link to comment
Share on other sites

you can try to use only one main loop with one $msg = GUIGetMsg() in it and it will (that will) recive msgs from all guis, in that loop you can handle msgs from all 3 gui-s

so instead creating new guis and trapping your self in 3 loops, just create one loop and create or hide guis according to your need with no additional loops

when you create one gui you can delite oldone with GUIDelete but if your using one loop i whud suggest hidding instead deliting with GUISetState(@SW_HIDE) and or predeclare variables

#include <GUIConstantsEx.au3>
Example()
Func Example()
Local $Button_1, $Button_2, $msg
$gui1 = GUICreate("My GUI Button1",Default,Default,0,0)
$Button_1 = GUICtrlCreateButton("Button Test 1", 0, -1)
GUISetState()
$gui2 = GUICreate("My GUI Button2")
$Button_2 = GUICtrlCreateButton("Button Test 2", 0, -1)

; Run the GUI until the dialog is closed
While 1
     $msg = GUIGetMsg()
     Select
         Case $msg = $GUI_EVENT_CLOSE
             ExitLoop
         Case $msg = $Button_1
             GUISetState(@SW_HIDE,$gui1)
             GUISetState(@SW_SHOW,$gui2)
             MsgBox(0, 'Testing', 'Button 1 was pressed')
         Case $msg = $Button_2
             GUISetState(@SW_HIDE,$gui2)
             GUISetState(@SW_SHOW,$gui1)
             MsgBox(0, 'Testing', 'Button 2 was pressed')
     EndSelect
WEnd
EndFunc ;==>Example
Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

here's my take on it. :P

; *** Start added by AutoIt3Wrapper ***
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
; *** End added by AutoIt3Wrapper ***
#cs ----------------------------------------------------------------------------

AutoIt Version: 3.3.8.1
Author: myName

Script Function:
Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here
#AutoIt3Wrapper_Add_Constants=n


Global $msg, $mainMenu, $wButton, $mainMenu1, $Welcome, $Intro

Intro1()

mainMenu1()

startHere1()

intro1()

mainMenu1()

startHere1()

Func intro1()
     $Intro = GUICreate("Welcome", 472, 309, 192, 124)
     $Label1 = GUICtrlCreateLabel("Welcome to the TruTops Programming Guide.", 45, 8, 400, 34, $SS_CENTER)
     GUICtrlSetFont(-1, 20, 800, 2, "AriaScriptSSK")
     $Label2 = GUICtrlCreateLabel("This guide was created to help the user in programming TruTops Mark.", 67, 56, 337, 17, $SS_CENTER)
     $Label3 = GUICtrlCreateLabel("We will go through all of the steps of each programming option in the TruTops Mark Program itself.", 3, 72, 465, 17, $SS_CENTER)
     $Label4 = GUICtrlCreateLabel("First, If you noticed, the door to the machine has already opened.", 80, 88, 310, 17, $SS_CENTER)
     $Label5 = GUICtrlCreateLabel("Before we begin, please clear off anything that may be in the way of the table movement.", 24, 104, 422, 17, $SS_CENTER)
     $Label6 = GUICtrlCreateLabel("Also, clear off the table with the acception of the A-Axis and the guide blocks that are in place.", 11, 120, 448, 17, $SS_CENTER)
     $Label7 = GUICtrlCreateLabel("Once that is done, Please proceed and click OK", 119, 136, 232, 17, $SS_CENTER)
     $Button1 = GUICtrlCreateButton("Continue", 104, 216, 75, 25)
     $Button2 = GUICtrlCreateButton("Exit", 296, 216, 75, 25)
     GUISetState()

     While 1
          $msg = GUIGetMsg()
          Select
               Case $msg = $GUI_EVENT_CLOSE
                    Exit
               Case $msg = $Button2
                    Exit
               Case $msg = $Button1
                    GUISetState(@SW_HIDE, $Intro)
                    mainMenu1()
                    GUISetState(@SW_SHOW, $Intro)
               Case $msg = $Button1
          EndSelect
     WEnd
EndFunc   ;==>intro1

Func mainMenu1()

     $mainMenu = GUICreate("Main Menu", 320, 282, 193, 125, -1, -1, $Welcome)
     $Label1 = GUICtrlCreateLabel("Please select a starting point below.", 73, 16, 173, 17)
     $Label2 = GUICtrlCreateLabel("Each button will open a more in depth set of options.", 34, 48, 251, 17)
     $startHere = GUICtrlCreateButton("Start Here", 122, 88, 75, 25)
     $axisCommands = GUICtrlCreateButton("Axis Commands", 114, 120, 91, 25)
     $markCommands = GUICtrlCreateButton("Mark Commands", 110, 152, 99, 25)
     $systemCommands = GUICtrlCreateButton("System Commands", 110, 184, 99, 25)
     $exit = GUICtrlCreateButton("Exit", 122, 216, 75, 25)
     GUISetState()

     While 1
          $msg = GUIGetMsg()
          Select
               Case $msg = $GUI_EVENT_CLOSE
                    Exit
               Case $msg = $exit
                    GUIDelete()
                    Return
               Case $msg = $startHere
                    GUISetState(@SW_HIDE,$mainMenu)
                    startHere1()
                    GUISetState(@SW_SHOW, $mainMenu)
          EndSelect
     WEnd
EndFunc   ;==>mainMenu1

Func startHere1()
     $pgStartHere = GUICreate("Start Here", 566, 525, 192, 124)
     $Edit1 = GUICtrlCreateEdit("", 32, 24, 489, 441, $ES_CENTER, $ES_READONLY)
     GUICtrlSetData(-1, StringFormat("This is Text"), $ES_READONLY)
     $_mainMenu = GUICtrlCreateButton("Main Menu", 120, 480, 75, 25)
     $exit = GUICtrlCreateButton("Exit", 360, 480, 75, 25)
     GUISetState(@SW_SHOW)

     While 1
          $msg = GUIGetMsg()
          Select
               Case $msg = $GUI_EVENT_CLOSE
                    Exit
               Case $msg = $exit
                    Exit
               Case $msg = $_mainMenu
                    GUIDelete()
                    Return
          EndSelect
     WEnd
EndFunc   ;==>startHere1

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

For shits and giggles and since I'm late to the party:

#include <GuiConstantsEx.au3>
#include <StaticConstants.au3>
#include <EditConstants.au3>

Global $pgstarthere = ''
Global $mainmenu    = ''

intro1()

Func intro1()
    Local Static $intro = GUICreate("Welcome", 472, 309, 192, 124)
    Local Static $label1 = GUICtrlCreateLabel("Welcome to the TruTops Programming Guide.", 45, 8, 400, 34, $ss_center)
    GUICtrlSetFont(-1, 20, 800, 2, "AriaScriptSSK")
    Local Static $label2 = GUICtrlCreateLabel("This guide was created to help the user in programming TruTops Mark.", 67, 56, 337, 17, $ss_center)
    Local Static $label3 = GUICtrlCreateLabel("We will go through all of the steps of each programming option in the TruTops Mark Program itself.", 3, 72, 465, 17, $ss_center)
    Local Static $label4 = GUICtrlCreateLabel("First, If you noticed, the door to the machine has already opened.", 80, 88, 310, 17, $ss_center)
    Local Static $label5 = GUICtrlCreateLabel("Before we begin, please clear off anything that may be in the way of the table movement.", 24, 104, 422, 17, $ss_center)
    Local Static $label6 = GUICtrlCreateLabel("Also, clear off the table with the acception of the A-Axis and the guide blocks that are in place.", 11, 120, 448, 17, $ss_center)
    Local Static $label7 = GUICtrlCreateLabel("Once that is done, Please proceed and click OK", 119, 136, 232, 17, $ss_center)
    Local Static $button1 = GUICtrlCreateButton("Continue", 104, 216, 75, 25)
    Local Static $button2 = GUICtrlCreateButton("Exit", 296, 216, 75, 25)

    GUISetState()

    While 1
        Switch GUIGetMsg()
            Case $gui_event_close, $button2
                Exit
            Case $button1
                mainMenu1()
        EndSwitch
    WEnd
EndFunc   ;==>intro1

Func mainMenu1()
    $mainmenu = GUICreate("Main Menu", 320, 282, 193, 125, -1, -1)
    Local $label1 = GUICtrlCreateLabel("Please select a starting point below.", 73, 16, 173, 17)
    Local $label2 = GUICtrlCreateLabel("Each button will open a more in depth set of options.", 34, 48, 251, 17)
    Local $starthere = GUICtrlCreateButton("Start Here", 122, 88, 75, 25)
    Local $axiscommands = GUICtrlCreateButton("Axis Commands", 114, 120, 91, 25)
    Local $markcommands = GUICtrlCreateButton("Mark Commands", 110, 152, 99, 25)
    Local $systemcommands = GUICtrlCreateButton("System Commands", 110, 184, 99, 25)
    Local $exit = GUICtrlCreateButton("Exit", 122, 216, 75, 25)

    GUISetState(@SW_SHOWNORMAL)

    GUISwitch($mainmenu)

    While 1
        Switch GUIGetMsg()
            Case $gui_event_close
                Exit
            Case $exit
                GUIDelete($mainmenu)
                intro1()
            Case $starthere
                GUIDelete($mainmenu)
                startHere1()
        EndSwitch
    WEnd
EndFunc   ;==>mainMenu1

Func startHere1()
    $pgstarthere = GUICreate("Start Here", 566, 525, 192, 124)
    Local $edit1 = GUICtrlCreateEdit("", 32, 24, 489, 441, $es_center, $es_readonly)
    GUICtrlSetData(-1, StringFormat("This is Text"), $es_readonly)
    Local $_mainmenu = GUICtrlCreateButton("Main Menu", 120, 480, 75, 25)
    Local $exit = GUICtrlCreateButton("Exit", 360, 480, 75, 25)

    GUISetState(@SW_SHOWNORMAL)

    GUISwitch($pgstarthere)

    While 1
        Switch GUIGetMsg()
            Case $gui_event_close, $exit
                Exit
            Case $_mainmenu
                GUIDelete($pgstarthere)
                mainMenu1()
        EndSwitch
    WEnd
EndFunc   ;==>startHere1
Edited by LaCastiglione
Link to comment
Share on other sites

Recursion warning!!!

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

ok when i tupe on google Recursion (copy paste) google try to correct me in the loop like crazy, must be some crazzy google joke

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

I find it funny that when you correctly spell the word recursion on Google search it gives you "Did you mean: Recursion ", so as BogQ says, probably some kind of google joke.

Edited by BrewManNH

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

well BrewManNH at least i know JohnOne got the joke on first try ^^ (thumbs up :P)

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

A crash isn't likely to happen in this script, but bad programming technique none-the-less.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

BUt the GUIs are deleted though.

Edit: Ok, I see, yeah. Well, it isn't likely to happen though.

Perhaps not, but good coding should be a precise thing, and have

contingencies for all scenarios.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Hey everyone, I do appreciate everything. I know I don't have very good etiquette when it comes to programming, I am an animator that is dabbling. I am writing this for the place I work. I don't plan on being there forever and am writing a cheat sheet for the guy that will one day take my place (whoever that will be). I looked over the code and will try it out as soon as I can. I will post the results when I can.

Since my order of scripting is not in the correct order, I was wondering if someone can point me in the direction of a program that could show me the correct structure to use. The help docs don't really do that. Like I said, I haven't been in this scene for long. So any help would be most appreciated.

Thanks again,

Link to comment
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
 Share

  • Recently Browsing   0 members

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