Jump to content
JuanFelipe

GUI IN GUI

Recommended Posts

JuanFelipe
Hello friends,
I would like to know how to open a GUI from another GUI, I did it the way I leave the attached code, but when closing the second GUI they all close, they could help me to solve this problem without compiling another script. Thank you
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("Form1", 173, 126, 192, 124)
$Button1 = GUICtrlCreateButton("Button1", 16, 24, 75, 25)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

         Case $Button1
            _form2()

    EndSwitch
WEnd

;================================================= GUI 2
Func _form2()
$Form1 = GUICreate("Form2", 615, 437, 192, 124)
GUISetState(@SW_SHOW)
While 2
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
       Exit
    EndSwitch
WEnd
EndFunc

 

Share this post


Link to post
Share on other sites
Melba23

JuanFelipe,

I suggest reading the Managing Multiple GUIs tutorial in the Wiki - that will explain how to do it.

M23

 

  • Like 1

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
Subz

Couple of pointers:

  1. Always rename your Guis differently e.g. in your code you have main Gui called Form1 and additional Gui also named Form1, doing so allows you to target the correct Gui.
  2. Don't use Exit unless you wish to close your entire script, instead Exit the loop and use GuiDelete.

But as Melba23 mentioned read the link he provided and also the help file.

  • Like 1

Share this post


Link to post
Share on other sites
JuanFelipe

Thanks! I will try.

Share this post


Link to post
Share on other sites
KickStarter15

@JuanFelipe,

Something like this.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("Form1", 173, 126, 192, 124)
$Button1 = GUICtrlCreateButton("Button1", 16, 24, 75, 25)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

         Case $Button1
            _form2()

    EndSwitch
WEnd

;================================================= GUI 2
Func _form2()
$Form2 = GUICreate("Form2", 615, 437, 192, 124)
GUISetState(@SW_SHOW)
While 2
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
      GUIDelete($Form2)
      GUISetState(@SW_ENABLE, $Form1)
      Return
    EndSwitch
WEnd
EndFunc

 


Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare.

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

  • Similar Content

    • BogdanNicolescu
      By BogdanNicolescu
      While 1 / / / A whole bunch of codes found in help and here: https://www.autoitscript.com/autoit3/docs/ / / / WEnd OR:

       
      HotKeySet("{ESC}", "Terminate") While 1 MouseClick("Right",674,422) MouseClick("Left",673,447) Sleep(2000) / / / A whole bunch of codes found in help and here: https://www.autoitscript.com/autoit3/docs/ / / / MouseClick("Left",675,339) SLeep(3000) WEnd Func Terminate()     Exit 0 EndFunc  
      Sorry if i should't let this here to be found by newbies like me -.-'
    • santoshM
      By santoshM
      Dear friends i am facing a problem , i have created a window in autoit some time it is moving with the mouse curser even if iam not clicking the window 
    • sumanth1980
      By sumanth1980
      Here i am wrote a simple lines to install basic applications but when i clicked on one application/program to install it was working fine but when i cancel the program in the middle to install another program it was not working. I am not an expert in this but i want a solution for this ... Can any one help me on this....
      ORG-1.au3
    • PleaseHelpMEIWillLoveyou
      By PleaseHelpMEIWillLoveyou
      Is there a way to use a custom terminal or something from my pc and run a script on another pc.
      please let me know if its possible
      (not for anything bad just for a project im working on)
    • juniq
      By juniq
      Hey I'm writing on a script which places a link in the context menu so you can choose several mp3 files and rename them using id3 tag udf and year / time stuff variables.
      My problem: I'm renaming the files through "FileMove", But HOW can I get the current directory of the chosen files only? I can't use stringsplit cz there are more than 1 delimiter "\". and I can't trim the string because the stringlength changes every time. How can I get ONLY the directory where the files from $cmdline chosen are? 
×