Sign in to follow this  
Followers 0
Moose23

Re-opening Guis

8 posts in this topic

#1 ·  Posted (edited)

Howdy folks!

Been tampering around with Autoit today (complete newbie) and i managed to come up with a little shortcut thing for my college work at school.

The only problem is, when i close a child gui, the parent gui refuses to open up another instance, and i for the life of me i cannot work out a way around it, can anyone help me? D:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <guiconstants.au3>;;needed for the gui events
#Region ### START Koda GUI section ### Form=f:\autoit3\scripts\memory stick hub.kxf
$hGuiParent = GUICreate("Memory Hub", 285, 171, 192, 124)
$Group1 = GUICtrlCreateGroup("", 8, 8, 265, 153)
$Auto = GUICtrlCreateButton("AutoIt Manager", 152, 112, 105, 41)
$Brow = GUICtrlCreateButton("Browsers", 24, 112, 105, 41)
$Prog = GUICtrlCreateButton("Programs", 24, 64, 105, 41)
$Work = GUICtrlCreateButton("Work Folder", 152, 64, 105, 41)
$Label1 = GUICtrlCreateLabel("Input Drive Letter", 26, 16, 86, 17)
$Drive = GUICtrlCreateInput("", 25, 35, 97, 21)
$OK = GUICtrlCreateButton("OK", 127, 32, 41, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit");;links to the quit function, important to actually close the script
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
EndSwitch
$Dvltr = "NULL"
Switch $nMsg
  Case $OK
   $read = GUICtrlRead($Drive)
   $Dvltr = $read
   MsgBox(0,"Drive","You selected Drive: " & $Dvltr)
EndSwitch
Switch $nMsg ;;AutoIt
Case $Auto
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <guiconstants.au3> ;;sets up the child closing
Opt("GuiOnEventMode", 1) ;; turns on the gui event mode
#Region ### START Koda GUI section ### Form=f:\autoit3\scripts\autoit manager gui with input.kxf
$hGuiChild = GUICreate("AutoIt Manager", 219, 119, 520, 183)
$Group1 = GUICtrlCreateGroup("", 0, 0, 217, 113)
$Run = GUICtrlCreateButton("Autoit Run", 16, 64, 89, 41)
$Script = GUICtrlCreateButton("Autoit Scripter", 16, 16, 89, 41)
$GUI = GUICtrlCreateButton("Autoit GUI", 112, 16, 89, 41)
$Exe = GUICtrlCreateButton("Exe Compiler", 112, 64, 89, 41)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
GUISetOnEvent($GUI_EVENT_CLOSE, "_closechild");;event which states when the gui is closed, the closechild function will occur
GUISetState();;this....this is needed.
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
EndSwitch
 
Switch $nMsg
Case $Script
  $read = GUICtrlRead($Drive)
  $Dvltr = $read
  run($Dvltr & ":\Autoit3\AutoIt3\SciTE\SciTE.exe")
EndSwitch
Switch $nMsg
Case $Run
  $read = GUICtrlRead($Drive)
  $Dvltr = $read
  run($Dvltr & ":\Autoit3\AutoIt3\Autoit3.exe")
EndSwitch
Switch $nMsg
Case $GUI
  $read = GUICtrlRead($Drive)
  $Dvltr = $read
  run($Dvltr & ":\Autoit3\koda_1.7.3.0\FD.exe")
EndSwitch
Switch $nMsg
Case $Exe
  $read = GUICtrlRead($Drive)
  $Dvltr = $read
  run($Dvltr & ":\Autoit3\AutoIt3\Aut2Exe\Aut2exe.exe")
EndSwitch
WEnd
func _closechild();;the closng child function
    GUIDelete($hGuiChild)
EndFunc
EndSwitch
 
Switch $nMsg ;;Browsers
Case $Brow
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <guiconstants.au3>
Opt("GuiOnEventMode", 1)
#Region ### START Koda GUI section ### Form=F:\Autoit3\Scripts\Broswer GUI.kxf
$hGuiChild = GUICreate("Browser Hub", 251, 59, 192, 124)
$Iron = GUICtrlCreateButton("Iron", 8, 8, 105, 41)
$Avant = GUICtrlCreateButton("Avant", 136, 8, 105, 41)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
GUISetOnEvent($GUI_EVENT_CLOSE, "_closechild")
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
EndSwitch
Switch $nMsg
Case $Iron
  $read = GUICtrlRead($Drive)
  $Dvltr = $read
  run($Dvltr & ":\IronPortable\IronPortable.exe")
EndSwitch
Switch $nMsg
Case $Avant
  $read = GUICtrlRead($Drive)
  $Dvltr = $read
  run($Dvltr & ":\avant\avant.exe")
EndSwitch
WEnd
Return(closechild()) ;;Return is used to call upon a function
EndSwitch
Switch $nMsg ;;Programs
Case $Prog
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <guiconstants.au3>
Opt("GuiOnEventMode", 1)
#Region ### START Koda GUI section ### Form=F:\Autoit3\Scripts\Program Gui gui.kxf
$hGuiChild = GUICreate("Program Hub", 251, 59, 192, 124)
$php = GUICtrlCreateButton("Easy PHP", 8, 8, 105, 41)
$Note = GUICtrlCreateButton("Notepad++", 136, 8, 105, 41)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
GUISetOnEvent($GUI_EVENT_CLOSE, "_closechild")
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
EndSwitch
Switch $nMsg
Case $php
  $read = GUICtrlRead($Drive)
  $Dvltr = $read
  run($Dvltr & ":\EasyPHP-5.3.8.0\EasyPHP-5.3.8.0.exe")
EndSwitch
Switch $nMsg
Case $Note
  $read = GUICtrlRead($Drive)
  $Dvltr = $read
  run($Dvltr & ":\Notepad++\notepad++.exe")
EndSwitch
WEnd
Return(closechild())
EndSwitch
Switch $nMsg ;;Folder
Case $Work
  $read = GUICtrlRead($Drive)
  $Dvltr = $read
  Run("Explorer.exe " & $Dvltr & ":\Super Happy Fun Time Work")
EndSwitch
 
WEnd
Func _Quit()
    Exit
EndFunc

thanks in advance

Edited by Moose23

Share this post


Link to post
Share on other sites



Moose23,

Welcome to the AutoIt forum. :graduated:

Without wishing to sound discouraging - where to start! :)

That was a real mash-up of a script if ever I saw one - I think you need to stop and learn a bit more about AutoIt and how to use the GUI modes before you go any further or you are going to get very frustrated. ;)

Reading the Help file (at least the first few sections - Using AutoIt, Tutorials and the first couple of References) will help you enormously. You should also look at the excellent tutorials that you will find here and here - you will find other tutorials in the Wiki (the link is at the top of the page).

Here is a version of you script that I have cleared up a bit. Note that I changed the Koda path to match my machine for testing to make sure it works. Take a look at it and note the differences from yours. Look in the Help file and read those tutorials to see if you can understand why I have changed things.

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

$hGuiParent = GUICreate("Memory Hub", 285, 171, 192, 124)
$Group1 = GUICtrlCreateGroup("", 8, 8, 265, 153)
$Auto = GUICtrlCreateButton("AutoIt Manager", 152, 112, 105, 41)
$Brow = GUICtrlCreateButton("Browsers", 24, 112, 105, 41)
$Prog = GUICtrlCreateButton("Programs", 24, 64, 105, 41)
$Work = GUICtrlCreateButton("Work Folder", 152, 64, 105, 41)
$Label1 = GUICtrlCreateLabel("Input Drive Letter", 26, 16, 86, 17)
$Drive = GUICtrlCreateInput("", 25, 35, 97, 21)
$OK = GUICtrlCreateButton("OK", 127, 32, 41, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)

$Dvltr = "NULL"

While 1

    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $OK
            $Dvltr = GUICtrlRead($Drive)

            MsgBox(0, "Drive", "You selected Drive: " & $Dvltr)
        Case $Auto
            $hGuiChild = GUICreate("AutoIt Manager", 219, 119, 520, 183)
            $Group2 = GUICtrlCreateGroup("", 0, 0, 217, 113)
            $Run = GUICtrlCreateButton("Autoit Run", 16, 64, 89, 41)
            $Script = GUICtrlCreateButton("Autoit Scripter", 16, 16, 89, 41)
            $GUI = GUICtrlCreateButton("Autoit GUI", 112, 16, 89, 41)
            $Exe = GUICtrlCreateButton("Exe Compiler", 112, 64, 89, 41)
            GUICtrlCreateGroup("", -99, -99, 1, 1)
            GUISetState(@SW_SHOW)
            While 1
                $nMsg = GUIGetMsg()
                Switch $nMsg
                    Case $GUI_EVENT_CLOSE
                        GUIDelete($hGuiChild)
                        ExitLoop
                    Case $Script
                        $Dvltr = GUICtrlRead($Drive)

                        Run($Dvltr & ":\Autoit3\AutoIt3\SciTE\SciTE.exe")
                    Case $Run
                        $Dvltr = GUICtrlRead($Drive)

                        Run($Dvltr & ":\Autoit3\AutoIt3\Autoit3.exe")
                    Case $GUI
                        $Dvltr = GUICtrlRead($Drive)
                        
                        Run($Dvltr & ":\Program Files\AutoIt3\Koda\FD.exe") ; Changed to my path for testing
                    Case $Exe
                        $Dvltr = GUICtrlRead($Drive)

                        Run($Dvltr & ":\Autoit3\AutoIt3\Aut2Exe\Aut2exe.exe")
                EndSwitch
            WEnd
        Case $Brow
            $hGuiChild = GUICreate("Browser Hub", 251, 59, 192, 124)
            $Iron = GUICtrlCreateButton("Iron", 8, 8, 105, 41)
            $Avant = GUICtrlCreateButton("Avant", 136, 8, 105, 41)
            GUISetState(@SW_SHOW)

            While 1
                $nMsg = GUIGetMsg()
                Switch $nMsg
                    Case $GUI_EVENT_CLOSE
                        GUIDelete($hGuiChild)
                        ExitLoop
                    Case $Iron
                        $Dvltr = GUICtrlRead($Drive)

                        Run($Dvltr & ":\IronPortable\IronPortable.exe")
                    Case $Avant
                        $Dvltr = GUICtrlRead($Drive)

                        Run($Dvltr & ":\avant\avant.exe")
                EndSwitch
            WEnd
        Case $Prog
            $hGuiChild = GUICreate("Program Hub", 251, 59, 192, 124)
            $php = GUICtrlCreateButton("Easy PHP", 8, 8, 105, 41)
            $Note = GUICtrlCreateButton("Notepad++", 136, 8, 105, 41)
            GUISetState(@SW_SHOW)

            While 1
                $nMsg = GUIGetMsg()
                Switch $nMsg
                    Case $GUI_EVENT_CLOSE
                        GUIDelete($hGuiChild)
                        ExitLoop
                    Case $php
                        $Dvltr = GUICtrlRead($Drive)

                        Run($Dvltr & ":\EasyPHP-5.3.8.0\EasyPHP-5.3.8.0.exe")
                    Case $Note
                        $Dvltr = GUICtrlRead($Drive)

                        Run($Dvltr & ":\Notepad++\notepad++.exe")
                EndSwitch
            WEnd
        Case $Work
            $Dvltr = GUICtrlRead($Drive)

            Run("Explorer.exe " & $Dvltr & ":\Super Happy Fun Time Work")
    EndSwitch

WEnd

Please ask if there is anything you do not understand - although I do not expect questions in the next 5 minutes. :D

Please take some time to read and digest the tuorials. I know you want to start coding NOW, but a little study will save you a lot of trouble later on, believe me. :D

You know where I am when you need more information. ;)

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

haha!

through reading yours i can see what i've done exactly :graduated:

i'll be honest, i did slap that code together while floundering around with the beginnings xD

guess i should really look at tutorials without bowling in headlong xD

thanks alot for your help!

Share this post


Link to post
Share on other sites

Moose23,

guess i should really look at tutorials without bowling in headlong

It does help. :graduated:

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

oh, on a side thought, is there a way to display two child gui's at once?

i know i could make a large parent gui instead, but would be interesting to know ;D

and if there is a tutorial about it already, tell me, i'll slap myself and get right on it :graduated:

Share this post


Link to post
Share on other sites

Moose23,

Displaying multiple GUIs is quite possible - if a little complex to manage. I would recommend the Managing Multiple GUIs tutorial in the Wiki as a good start point. :graduated:

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

kay, i slapped myself and now i'll head on through these tutorials

thanks again!

Share this post


Link to post
Share on other sites

Moose23,

A pleasure. See you again soon no doubt. :graduated:

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

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  
Followers 0