Jump to content

Stop Case when a Function ( GUI ) got closed


Recommended Posts

Hi! I have a main GUI and there I call on button press 5 functions which are all new guis which go through 1 by 1 till end. In my Button case from main gui it looks like this:

 

Case $Btn1 

Function1()

Function2()

Function3()

 

I'm currently wondering on how i can stop running as example function3 when user pressed close button in gui2 ( function2 ). So Actually all I search is to stop the Case running when one windows close got pressed.

 

 

thanks in advance

Link to comment
Share on other sites

#include <GUIConstantsEx.au3>
 
 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
         Switch GUIGetMsg()
             Case $GUI_EVENT_CLOSE
                 ExitLoop
             Case $hButton1
                 MsgBox("", "MsgBox 1", "Test from Gui 1")
             Case $hButton2
                 ; Disable the first GUI
                 GUISetState(@SW_DISABLE, $hGUI1)
                 gui2()
                 gui3()
                 gui4()
                 ; Re-enable the first GUI
                 GUISetState(@SW_ENABLE, $hGUI1)
         EndSwitch
     WEnd
 EndFunc   ;==>gui1
 
 Func gui2()
     $hGUI2 = GUICreate("Gui 2", 200, 200, 350, 350)
     $hButton3 = GUICtrlCreateButton("MsgBox 2", 10, 10, 80, 30)
     GUISetState()
 
     While 1
         ; We can only get messages from the second GUI
         Switch GUIGetMsg()
             Case $GUI_EVENT_CLOSE
                 GUIDelete($hGUI2)
                 ExitLoop
             Case $hButton3
                 MsgBox("", "MsgBox 2", "Test from Gui 2")
        EndSwitch
    WEnd
 EndFunc   ;==>gui2
 
  Func gui3()
     $hGUI3 = GUICreate("Gui 2", 200, 200, 350, 350)
     $hButton3 = GUICtrlCreateButton("MsgBox 2", 10, 10, 80, 30)
     GUISetState()
 
     While 1
         ; We can only get messages from the second GUI
         Switch GUIGetMsg()
             Case $GUI_EVENT_CLOSE
                 GUIDelete($hGUI3)
                 ExitLoop
             Case $hButton3
                 MsgBox("", "MsgBox 2", "Test from Gui 2")
        EndSwitch
    WEnd
 EndFunc   ;==>gui3
 
  Func gui4()
     $hGUI4 = GUICreate("Gui 2", 200, 200, 350, 350)
     $hButton3 = GUICtrlCreateButton("MsgBox 2", 10, 10, 80, 30)
     GUISetState()
 
     While 1
         ; We can only get messages from the second GUI
         Switch GUIGetMsg()
             Case $GUI_EVENT_CLOSE
                 GUIDelete($hGUI4)
                 ExitLoop
             Case $hButton3
                 MsgBox("", "MsgBox 2", "Test from Gui 2")
        EndSwitch
    WEnd
 EndFunc   ;==>gui2

Normally you would go to next function when button next is pressed and so on. but want to have when close is pressed that the case wont get run through anymore

Link to comment
Share on other sites

28 minutes ago, Sturmi said:

and in which way does this help me to stop my case to go through all functions ?

it helps me to help you. I am not interestet to do a work you can do yourself. And make a real example:

and in which way does this help me to stop my case to go through all functions ?

Link to comment
Share on other sites

Sturmi we encoutering the same issue i guess i whould like to stop a case also and the tips given to me by all other user is : 

"Make your own timer"

Watxh this:

 

Or folow this : 

 

 

Hope it gonna help you but i am still stuck :(  

 

 

the tutorial is here btw. 

https://www.autoitscript.com/wiki/Interrupting_a_running_function i dont understand it. good luck !

Edited by caramen

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

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...