Jump to content

How to stop/pause GUI script while the script function is running


Recommended Posts

GUI script

While 1
    $msg = GUIGetMsg()
    
    Switch $msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $Button1
            Button1_func()
        Case $Button2
            Exit

Func Button1_func()
;The function will run a applicaton for a long time.
EndFunc

How can I stop/pasue the script when click $Button2.

Now the problem I encountered was when I click $Button2 after $Button1, $Button2 has no effect, it run well if click $Button2 only, I thought it's the Button1_func() was still running casued, how can I stop/pause the script?

Edited by yarsye
Link to comment
Share on other sites

I don't want the hotkey.

I want the one button to Start and another to Stop, it's difficult to add a check in the Button1_func(), the function will call many other functions. So I want to use a function to Button1_func() when clicking Button2, just like

While 1
    $msg = GUIGetMsg()
    
    Switch $msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $Button1
            Button1_func()
        Case $Button2
            StopButton1_fun()
            Exit

Whether my idea is realizable? How can stop a function while it's running?

Edited by yarsye
Link to comment
Share on other sites

Could do somthing like this, but its untested just giving you an idea.

While 1
    $msg = GUIGetMsg()
    
    Switch $msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $Button1
            $Pause = 1
                 While $Pause = 1
                        sleep(100)
                  Wend
        Case $Button2
            $Pause = 0
Wend
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...