Sign in to follow this  
Followers 0
Swatty43

GUI crashing problem

3 posts in this topic

Hi Everyone,

I have a really weird issue, I have a script that I wrote a  "Setup utility" for our new computers we get at work. I have multiple GUIs, and my script seems to hang and crash only when I exit out of my second GUI but only after launching the second GUI and clicking on a button to perform a task. I then go back to the first GUI and try to relaunch my second GUI and AutoIT crashes. Any ideas? Here is my code:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Version=Beta
#AutoIt3Wrapper_Add_Constants=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.10.2
 Author:         Mike Swatek

 Script Function:
    C1 Setup Utility 2.0 w GUI

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

; Script Start - Add your code below here
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>

#RequireAdmin

Opt("GUIOnEventMode", 1)

Global $hGUI1, $hGUI2 , $hButton1 = 9999 , $hGUI3 , $hButton2 = 9999 , $hButton3 = 9999 , $hButton4 = 9999 , $hButton5 = 9999
Global $hButton6 = 9999 , $hButton7 = 9999 , $hButton8 = 9999 , $hButton9 = 9999 , $hButton10 = 9999 , $hButton11 = 9999 , $hButton12 = 9999 , $hButton13 = 9999 , $hButton14 = 9999
Global $hButton15 = 9999 , $hButton16 = 9999 , $hButton17 = 9999 , $hButton18 = 9999 , $hButton19 = 9999 , $hButton20 = 9999 , $hButton21 = 9999 , $hButton22 = 9999 , $hButton23 = 9999
Global $hButton24 = 9999 , $hButton25 = 9999 , $hButton26 = 9999 , $hButton27 = 9999
Global $Gui1MenuFile , $Gui1FileExit , $Gui1MenuHelp , $Gui1MenuAbout , $Gui1MenuInfo , $Gui2MenuFile , $Gui2FileExit , $Gui2MenuHelp , $Gui2MenuAbout , $Gui2MenuInfo , $Gui2MenuPro , $Gui2MenuUni, $Gui2MenuExp , $Gui2MenuAuto , $Gui2MenuCC
Global $Gui3MenuFile , $Gui3FileExit , $Gui3MenuHelp , $Gui3MenuAbout , $Gui3MenuInfo , $CMD1 ,$PowerTweaks , $Favorites

 gui1()

 Func gui1()
     $hGUI1 = GUICreate("C1 Setup Utility", 772, 399, 297, 178)
GUISetOnEvent($GUI_EVENT_CLOSE, "On_Close") ; Call a common GUI close function
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
$Gui1MenuFile = GUICtrlCreateMenu("&File")
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
$Gui1FileExit = GUICtrlCreateMenuItem("Exit", $Gui1MenuFile)
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
$Gui1MenuHelp = GUICtrlCreateMenu("&Help")
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
$Gui1MenuAbout = GUICtrlCreateMenuItem("About", $Gui1MenuHelp)
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
$Gui1MenuInfo = GUICtrlCreateMenuItem("Info", $Gui1MenuHelp)
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
$Pic1 = GUICtrlCreatePic("C:\Users\mswatek\Desktop\AutoIT\BG.jpg", 0, 0, 769, 377)
$Pic2 = GUICtrlCreatePic("C:\Users\mswatek\Desktop\AutoIT\Composite-One-300x280Grey.gif", 24, 88, 233, 193)
GUICtrlSetState($Pic1,$GUI_DISABLE)
GUISetFont(12, 800, 0, "Terminal")
$Label1 = GUICtrlCreateLabel("Welcome to the C1 Setup Utility", 192, 16, 407, 20)
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlSetBkColor(-1, 0xC0C0C0)
$Label2 = GUICtrlCreateLabel("This program will allow you to setup and confingure new PC's", 200, 32, 404, 21)
GUICtrlSetFont(-1, 11, 800, 0, "Times New Roman")
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlSetBkColor(-1, 0xC0C0C0)
$Label3 = GUICtrlCreateLabel("1.", 317, 112, 19, 26)
GUICtrlSetFont(-1, 14, 800, 0, "Times New Roman")
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlSetBkColor(-1, 0xC0C0C0)
$hButton1 = GUICtrlCreateButton("Enable/Config Admin", 341, 112, 123, 25)
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
GUICtrlSetFont(-1, 10, 800, 0, "Times New Roman")
$Label4 = GUICtrlCreateLabel("2.", 504, 112, 19, 26)
GUICtrlSetFont(-1, 14, 800, 0, "Times New Roman")
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlSetBkColor(-1, 0xC0C0C0)
$hButton2 = GUICtrlCreateButton("Uninstall Bloat", 525, 113, 123, 25)
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
GUICtrlSetFont(-1, 10, 800, 0, "Times New Roman")
$Label5 = GUICtrlCreateLabel("3.", 317, 147, 19, 26)
GUICtrlSetFont(-1, 14, 800, 0, "Times New Roman")
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlSetBkColor(-1, 0xC0C0C0)
$hButton3 = GUICtrlCreateButton("NRT", 341, 146, 123, 25)
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
GUICtrlSetFont(-1, 10, 800, 0, "Times New Roman")
$Label6 = GUICtrlCreateLabel("4.", 504, 147, 19, 26)
GUICtrlSetFont(-1, 14, 800, 0, "Times New Roman")
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlSetBkColor(-1, 0xC0C0C0)
$hButton4 = GUICtrlCreateButton("C1 Installer", 525, 147, 123, 25)
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
GUICtrlSetFont(-1, 10, 800, 0, "Times New Roman")
$Label7 = GUICtrlCreateLabel("5.", 317, 180, 19, 26)
GUICtrlSetFont(-1, 14, 800, 0, "Times New Roman")
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlSetBkColor(-1, 0xC0C0C0)
$hButton5 = GUICtrlCreateButton("MyUnistaller", 341, 179, 123, 25)
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
GUICtrlSetFont(-1, 10, 800, 0, "Times New Roman")
$Label8 = GUICtrlCreateLabel("6.", 504, 181, 19, 26)
GUICtrlSetFont(-1, 14, 800, 0, "Times New Roman")
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlSetBkColor(-1, 0xC0C0C0)
$hButton6 = GUICtrlCreateButton("", 525, 180, 123, 25)
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
GUICtrlSetFont(-1, 10, 800, 0, "Times New Roman")
GUISetState()

     While 1
         Sleep(10)
     WEnd
 EndFunc   ;==>gui1

 Func gui2()
     $hGUI2 = GUICreate("C1 Installer", 772, 399, 297, 178)
GUISetOnEvent($GUI_EVENT_CLOSE, "On_Close") ; Call a common GUI close function
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
$Gui2MenuFile = GUICtrlCreateMenu("&File")
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
$Gui2FileExit = GUICtrlCreateMenuItem("Exit", $Gui2MenuFile)
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
$Gui2MenuPro = GUICtrlCreateMenu("&Programs")
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
$Gui2MenuAuto = GUICtrlCreateMenuItem("Autoruns", $Gui2MenuPro)
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
$Gui2MenuCC = GUICtrlCreateMenuItem("CCleaner", $Gui2MenuPro)
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
$Gui2MenuExp = GUICtrlCreateMenuItem("Process Explorer", $Gui2MenuPro)
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
$Gui2MenuUni = GUICtrlCreateMenuItem("MyUninstaller", $Gui2MenuPro)
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
$Gui2MenuHelp = GUICtrlCreateMenu("&Help")
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
$Gui2MenuAbout = GUICtrlCreateMenuItem("About", $Gui2MenuHelp)
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
$Gui2MenuInfo = GUICtrlCreateMenuItem("Info", $Gui2MenuHelp)
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
$Pic1 = GUICtrlCreatePic("C:\Users\mswatek\Desktop\AutoIT\BG.jpg", 0, 0, 769, 377)
$Pic2 = GUICtrlCreatePic("C:\Users\mswatek\Desktop\AutoIT\Composite-One-300x280Grey.gif", 24, 88, 233, 193)
GUICtrlSetState($Pic1,$GUI_DISABLE)
GUISetFont(12, 800, 0, "Terminal")
$Label1 = GUICtrlCreateLabel("Welcome to the C1 Installer", 224, 16, 355, 20)
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlSetBkColor(-1, 0xC0C0C0)
$Label2 = GUICtrlCreateLabel("This program will allow you to install software", 264, 32, 301, 21)
GUICtrlSetFont(-1, 11, 800, 0, "Times New Roman")
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlSetBkColor(-1, 0xC0C0C0)
$Label3 = GUICtrlCreateLabel("1.", 333, 80, 19, 26)
GUICtrlSetFont(-1, 14, 800, 0, "Times New Roman")
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlSetBkColor(-1, 0xC0C0C0)
$hButton7 = GUICtrlCreateButton("Ketarin Installer", 357, 80, 123, 25)
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
GUICtrlSetFont(-1, 10, 800, 0, "Times New Roman")
$Label5 = GUICtrlCreateLabel("2.", 333, 115, 19, 26)
GUICtrlSetFont(-1, 14, 800, 0, "Times New Roman")
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlSetBkColor(-1, 0xC0C0C0)
$hButton8 = GUICtrlCreateButton("LogMeIn", 357, 114, 123, 25)
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
GUICtrlSetFont(-1, 10, 800, 0, "Times New Roman")
$Label7 = GUICtrlCreateLabel("3.", 333, 148, 19, 26)
GUICtrlSetFont(-1, 14, 800, 0, "Times New Roman")
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlSetBkColor(-1, 0xC0C0C0)
$hButton9 = GUICtrlCreateButton("NOD32", 357, 147, 123, 25)
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
GUICtrlSetFont(-1, 10, 800, 0, "Times New Roman")
$Label9 = GUICtrlCreateLabel("4.", 333, 178, 19, 26)
GUICtrlSetFont(-1, 14, 800, 0, "Times New Roman")
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlSetBkColor(-1, 0xC0C0C0)
$hButton10 = GUICtrlCreateButton("MXP", 357, 178, 123, 25)
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
GUICtrlSetFont(-1, 10, 800, 0, "Times New Roman")
$Label11 = GUICtrlCreateLabel("5.", 333, 213, 19, 26)
GUICtrlSetFont(-1, 14, 800, 0, "Times New Roman")
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlSetBkColor(-1, 0xC0C0C0)
$hButton11 = GUICtrlCreateButton("WG MVPN", 357, 212, 123, 25)
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
GUICtrlSetFont(-1, 10, 800, 0, "Times New Roman")
$Label4 = GUICtrlCreateLabel("6.", 520, 80, 19, 26)
GUICtrlSetFont(-1, 14, 800, 0, "Times New Roman")
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlSetBkColor(-1, 0xC0C0C0)
$hButton12 = GUICtrlCreateButton("Printers", 549, 81, 123, 25)
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
GUICtrlSetFont(-1, 10, 800, 0, "Times New Roman")
$Label6 = GUICtrlCreateLabel("7.", 520, 115, 19, 26)
GUICtrlSetFont(-1, 14, 800, 0, "Times New Roman")
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlSetBkColor(-1, 0xC0C0C0)
$hButton13 = GUICtrlCreateButton("Favorites", 549, 115, 123, 25)
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
GUICtrlSetFont(-1, 10, 800, 0, "Times New Roman")
$Label8 = GUICtrlCreateLabel("8.", 520, 149, 19, 26)
GUICtrlSetFont(-1, 14, 800, 0, "Times New Roman")
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlSetBkColor(-1, 0xC0C0C0)
$hButton14 = GUICtrlCreateButton("Power-Tweaks", 549, 148, 123, 25)
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
GUICtrlSetFont(-1, 10, 800, 0, "Times New Roman")
$hLabel10 = GUICtrlCreateLabel("9.", 520, 178, 29, 26)
GUICtrlSetFont(-1, 14, 800, 0, "Times New Roman")
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlSetBkColor(-1, 0xC0C0C0)
$hButton15 = GUICtrlCreateButton("Win Updates", 549, 179, 123, 25)
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
GUICtrlSetFont(-1, 10, 800, 0, "Times New Roman")
GUISetState()
 EndFunc   ;==>gui2


  Func gui3() ;C1 Printer Installer
$hGUI3 = GUICreate("C1 Printer Installer", 772, 399, 297, 178)
GUISetOnEvent($GUI_EVENT_CLOSE, "On_Close") ; Call a common GUI close function
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
$Gui3MenuFile = GUICtrlCreateMenu("&File")
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
$Gui3FileExit = GUICtrlCreateMenuItem("Exit", $Gui3MenuFile)
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
$Gui3MenuHelp = GUICtrlCreateMenu("&Help")
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
$Gui3MenuAbout = GUICtrlCreateMenuItem("About", $Gui3MenuHelp)
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
$Gui3MenuInfo = GUICtrlCreateMenuItem("Info", $Gui3MenuHelp)
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
$Pic1 = GUICtrlCreatePic("C:\Users\mswatek\Desktop\AutoIT\BG.jpg", 0, 0, 769, 377)
$Pic2 = GUICtrlCreatePic("C:\Users\mswatek\Desktop\AutoIT\Composite-One-300x280Grey.gif", 24, 88, 233, 193)
GUICtrlSetState($Pic1,$GUI_DISABLE)
GUISetFont(12, 800, 0, "Terminal")
$Label1 = GUICtrlCreateLabel("Welcome to the C1 Printer Installer", 160, 16, 459, 20)
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlSetBkColor(-1, 0xC0C0C0)
$Label2 = GUICtrlCreateLabel("This program will allow you to install network printers", 224, 32, 356, 21)
GUICtrlSetFont(-1, 11, 800, 0, "Times New Roman")
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlSetBkColor(-1, 0xC0C0C0)
$Label3 = GUICtrlCreateLabel("1.", 333, 112, 19, 26)
GUICtrlSetFont(-1, 14, 800, 0, "Times New Roman")
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlSetBkColor(-1, 0xC0C0C0)
$hButton16 = GUICtrlCreateButton("HP", 357, 112, 123, 25)
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
GUICtrlSetFont(-1, 10, 800, 0, "Times New Roman")
$Label4 = GUICtrlCreateLabel("2.", 520, 112, 19, 26)
GUICtrlSetFont(-1, 14, 800, 0, "Times New Roman")
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlSetBkColor(-1, 0xC0C0C0)
$hButton17 = GUICtrlCreateButton("Canon", 541, 113, 123, 25)
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
GUICtrlSetFont(-1, 10, 800, 0, "Times New Roman")
$Label5 = GUICtrlCreateLabel("3.", 333, 147, 19, 26)
GUICtrlSetFont(-1, 14, 800, 0, "Times New Roman")
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlSetBkColor(-1, 0xC0C0C0)
$hButton18 = GUICtrlCreateButton("Richo", 357, 146, 123, 25)
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
GUICtrlSetFont(-1, 10, 800, 0, "Times New Roman")
$Label6 = GUICtrlCreateLabel("4.", 520, 147, 19, 26)
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlSetBkColor(-1, 0xC0C0C0)
GUICtrlSetFont(-1, 14, 800, 0, "Times New Roman")
$hButton19 = GUICtrlCreateButton("Sharp", 541, 147, 123, 25)
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
GUICtrlSetFont(-1, 10, 800, 0, "Times New Roman")
$Label7 = GUICtrlCreateLabel("5.", 333, 180, 19, 26)
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlSetBkColor(-1, 0xC0C0C0)
GUICtrlSetFont(-1, 14, 800, 0, "Times New Roman")
$hButton20 = GUICtrlCreateButton("Xerox", 357, 179, 123, 25)
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
GUICtrlSetFont(-1, 10, 800, 0, "Times New Roman")
$Label8 = GUICtrlCreateLabel("6.", 520, 181, 19, 26)
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlSetBkColor(-1, 0xC0C0C0)
GUICtrlSetFont(-1, 14, 800, 0, "Times New Roman")
$hButton21 = GUICtrlCreateButton("Kill PrnSpl", 541, 180, 123, 25)
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
GUICtrlSetFont(-1, 10, 800, 0, "Times New Roman")
$hButton22 = GUICtrlCreateButton("", 357, 210, 123, 25)
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
GUICtrlSetFont(-1, 10, 800, 0, "Times New Roman")
$Label9 = GUICtrlCreateLabel("7.", 333, 210, 19, 26)
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlSetBkColor(-1, 0xC0C0C0)
GUICtrlSetFont(-1, 14, 800, 0, "Times New Roman")
$Label10 = GUICtrlCreateLabel("8.", 520, 210, 19, 26)
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlSetBkColor(-1, 0xC0C0C0)
GUICtrlSetFont(-1, 14, 800, 0, "Times New Roman")
$hButton23 = GUICtrlCreateButton("Start PrnSpl", 541, 211, 123, 25)
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
GUICtrlSetFont(-1, 10, 800, 0, "Times New Roman")
GUISetState()
 EndFunc   ;==>gui3


 func gui4()
$PowerTweaks = GUICreate("Power Tweaks", 258, 74, 600, 250)
$Pic1 = GUICtrlCreatePic("C:\Users\mswatek\Desktop\C1SetupUtility\Files\Tools\BG.jpg", 0, 0, 257, 73)
GUICtrlSetState($Pic1,$GUI_DISABLE)
GUISetOnEvent($GUI_EVENT_CLOSE, "On_Close") ; Call a common GUI close function
$hButton24 = GUICtrlCreateButton("Laptop", 34, 20, 83, 33)
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
GUICtrlSetFont(-1, 8, 800, 0, "Times New Roman")
$hButton25 = GUICtrlCreateButton("Desktop", 138, 20, 83, 33)
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
GUICtrlSetFont(-1, 8, 800, 0, "Times New Roman")
GUISetState(@SW_SHOW)
endfunc


 func gui5()
$Favorites = GUICreate("Favorites", 258, 74, 600, 250)
$Pic1 = GUICtrlCreatePic("C:\Users\mswatek\Desktop\C1SetupUtility\Files\Tools\BG.jpg", 0, 0, 257, 73)
GUICtrlSetState($Pic1,$GUI_DISABLE)
GUISetOnEvent($GUI_EVENT_CLOSE, "On_Close") ; Call a common GUI close function
$hButton26 = GUICtrlCreateButton("USA", 34, 20, 83, 33)
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
GUICtrlSetFont(-1, 8, 800, 0, "Times New Roman")
$hButton27 = GUICtrlCreateButton("CANADA", 138, 20, 83, 33)
GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function
GUICtrlSetFont(-1, 8, 800, 0, "Times New Roman")
GUISetState(@SW_SHOW)
endfunc

 Func On_Close()
     Switch @GUI_WINHANDLE ; See which GUI sent the CLOSE message
         Case $hGUI1
             Exit ; If it was this GUI - we exit <<<<<<<<<<<<<<<
         Case $hGUI2
             GUIDelete($hGUI2) ; If it was this GUI - we just delete the GUI <<<<<<<<<<<<<<<
             GUICtrlSetState($hButton4, $GUI_ENABLE)
             GUICtrlSetState($hGUI1, $GUI_ENABLE)
         Case $hGUI3
             GUIDelete($hGUI3) ; If it was this GUI - we just delete the GUI <<<<<<<<<<<<<<<
             GUICtrlSetState($hButton8, $GUI_ENABLE)
             GUICtrlSetState($hGUI2, $GUI_ENABLE)
         Case $PowerTweaks
             GUIDelete($PowerTweaks) ; If it was this GUI - we just delete the GUI <<<<<<<<<<<<<<<
             GUICtrlSetState($hGUI2, $GUI_ENABLE)
        Case $Favorites
             GUIDelete($Favorites) ; If it was this GUI - we just delete the GUI <<<<<<<<<<<<<<<
             GUICtrlSetState($hGUI2,$GUI_ENABLE)
        EndSwitch
 EndFunc

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi Swatty,

  Just a hunch after looking quickly over it:

In your On_close Function some cases are calling other GUI's that may have been closed, maybe add some checking like:

If $gui1 Exists Then

GulCtrlSetState(and so on...)

Bill

Edited by l3ill

Share this post


Link to post
Share on other sites

Hi Bill!

Thank you for the idea, but I think I solved my problem by using this as a template:

#include <GUIConstantsEx.au3>
 
 Global $hGUI2 = 9999, $hButton3 = 9999 ; Predeclare the variables with dummy values to prevent firing the Case statements
 
 gui1()
 
 Func gui1()
     $hGUI1 = GUICreate("Gui 1", 200, 200, 100, 100)
     $hButton1 = GUICtrlCreateButton("Msgbox 1", 10, 10, 80, 30)
     $hButton2 = GUICtrlCreateButton("Show Gui 2", 10, 60, 80, 30)
     GUISetState()
 
     While 1
         $aMsg = GUIGetMsg(1) ; Use advanced parameter to get array
         Switch $aMsg[1] ; check which GUI sent the message
             Case $hGUI1
                 Switch $aMsg[0] ; Now check for the messages for $hGUI1
                     Case $GUI_EVENT_CLOSE ; If we get the CLOSE message from this GUI - we exit <<<<<<<<<<<<<<<
                         ExitLoop
                     Case $hButton1
                         MsgBox("", "MsgBox 1", "Test from Gui 1")
                     Case $hButton2
                         GUICtrlSetState($hButton2, $GUI_DISABLE)
                         gui2()
                 EndSwitch
             Case $hGUI2
                 Switch $aMsg[0] ; Now check for the messages for $hGUI2
                     Case $GUI_EVENT_CLOSE ; If we get the CLOSE message from this GUI - we just delete the GUI <<<<<<<<<<<<<<<
                         GUIDelete($hGUI2)
                         GUICtrlSetState($hButton2, $GUI_ENABLE)
                     Case $hButton3
                         MsgBox("", "MsgBox", "Test from Gui 2")
                 EndSwitch
         EndSwitch
     WEnd
 EndFunc   ;==>gui1
 
 Func gui2()
     $hGUI2 = GUICreate("Gui 2", 200, 200, 350, 350)
     $hButton3 = GUICtrlCreateButton("MsgBox 2", 10, 10, 80, 30)
     GUISetState()
 EndFunc   ;==>gui2

I can now click on a button to launch a new GUI, click on a button on the new GUI, perform a task, then close the second GUI return to the first and then relaunch the second GUI without the script from crashing!

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