Jump to content
Sign in to follow this  
Sturmi

Stop Case when a Function ( GUI ) got closed

Recommended Posts

Sturmi

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

Share this post


Link to post
Share on other sites
Sturmi

i just added more sub guis to the example of autoit. works but im not sure how to interrupt when its in 1,2,3,4th window so it won't load the other if close is pressed

Share this post


Link to post
Share on other sites
AutoBert
5 hours ago, AutoBert said:

Please post a runable (reproducer) script showing your issue(s).

 

Share this post


Link to post
Share on other sites
Sturmi
#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

Share this post


Link to post
Share on other sites
Sturmi

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

Share this post


Link to post
Share on other sites
AutoBert
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 ?

Share this post


Link to post
Share on other sites
caramen

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

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.