yarsye Posted May 21, 2009 Share Posted May 21, 2009 (edited) 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 May 21, 2009 by yarsye Link to comment Share on other sites More sharing options...
Coolw Posted May 21, 2009 Share Posted May 21, 2009 Look up hotkeyset() in the help file. It will be called when you press a button. If you don't want the hotkey, you have to add a check inside the button1 function to see if button 2 was hit. My ProgramsMy WIP'sSteam Server Restarter Link to comment Share on other sites More sharing options...
yarsye Posted May 21, 2009 Author Share Posted May 21, 2009 (edited) 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 May 21, 2009 by yarsye Link to comment Share on other sites More sharing options...
Coolw Posted May 21, 2009 Share Posted May 21, 2009 (edited) Edit Yeah. I can't find any other way to do it unless you check to see if button2 was pressed within the function. Edited May 21, 2009 by Coolw My ProgramsMy WIP'sSteam Server Restarter Link to comment Share on other sites More sharing options...
TurionAltec Posted May 21, 2009 Share Posted May 21, 2009 check up "GUI OnEvent Mode" in the help file. With that when you press Button 2, it will "interrupt" the first function. Link to comment Share on other sites More sharing options...
Bam Posted May 22, 2009 Share Posted May 22, 2009 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now