Romm Posted February 1, 2008 Share Posted February 1, 2008 While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Case $msg = $start ;Do something While 1; Loop #2 ;Do something Wend EndSelect Wend How to stop Loop #2 with Stop button? Link to comment Share on other sites More sharing options...
GEOSoft Posted February 1, 2008 Share Posted February 1, 2008 While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Case $msg = $start ;Do something While 1; Loop #2 ;Do something Wend EndSelect Wend How to stop Loop #2 with Stop button?You will need to use adlib Look up AdlibEnable() George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Romm Posted February 1, 2008 Author Share Posted February 1, 2008 The only idea i have is: But it is incorrect AdlibEnable("myadlib") $stop = 1 While $stop = 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Case $msg = $stop_button $stop = 0 Case $msg = $start_button ;Do something While 1; Loop #2 ;Do something Wend EndSelect Wend Func myadlib() If $stop = 1 Then Exitloop EndIf EndFunc Link to comment Share on other sites More sharing options...
Romm Posted February 1, 2008 Author Share Posted February 1, 2008 Help guys Link to comment Share on other sites More sharing options...
james3mg Posted February 2, 2008 Share Posted February 2, 2008 (edited) The only idea i have is: But it is incorrect AdlibEnable("myadlib") $stop = 1 While $stop = 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Case $msg = $stop_button $stop = 0 Case $msg = $start_button ;Do something While 1; Loop #2 ;Do something Wend EndSelect Wend Func myadlib() If $stop = 1 Then Exitloop EndIf EndFuncNo, you've got to put the loop #2 stuff IN the adlib function - but don't have it loop, since the adlib function is called frequently. Then add a line at the very top of the adlib function:If $StopLoopTwo Then Return Now at the top of your script, declare $StopLoopTwo to be a global variable equal to 1. Enable the adlib loop. Now when you want to start loop 2, just set $StopLoopTwo=0 . When your stop button is clicked, have it set $StopLoopTwo to 1. Does that make sense? Edit: I'll probably be off now for the weekend, sorry. I just feel for you- I didn't want your question to get buried. I'll check back on Monday to see if you've worked it out. Otherwise, hopefully someone else can give you more timely advice. Edited February 2, 2008 by james3mg "There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110 Link to comment Share on other sites More sharing options...
Romm Posted February 2, 2008 Author Share Posted February 2, 2008 (edited) #include <GUIConstants.au3> AdlibEnable("myadlib") Global $stoploop = 0 GUICreate("My GUI Button"); will create a dialog box that when displayed is centered Opt("GUICoordMode",2) $Button_1 = GUICtrlCreateButton ("Run Notepad", 10, 30, 100) $Button_2 = GUICtrlCreateButton ( "Button Test", 0, -1) GUISetState () ; will display an dialog box with 2 button ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_1 $stoploop=0 Case $msg = $Button_2 $stoploop=1 EndSelect Wend Func myadlib() If $StopLoop = 0 Then Return MsgBox(1, "", "GO!") EndFunc All is ok with this...but if i use sleep, i cant exit loop... #include <GUIConstants.au3> AdlibEnable("myadlib") Global $stoploop = 0 GUICreate("My GUI Button"); will create a dialog box that when displayed is centered Opt("GUICoordMode",2) $Button_1 = GUICtrlCreateButton ("Run Notepad", 10, 30, 100) $Button_2 = GUICtrlCreateButton ( "Button Test", 0, -1) GUISetState () ; will display an dialog box with 2 button ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_1 $stoploop=0 Case $msg = $Button_2 $stoploop=1 EndSelect Wend Func myadlib() If $StopLoop = 0 Then Return MsgBox(1, "", "GO!") Sleep(1000) MsgBox(1, "", "GO2!") EndFunc Edited February 2, 2008 by Romm Link to comment Share on other sites More sharing options...
whim Posted February 2, 2008 Share Posted February 2, 2008 (edited) maybe this is what you want ? #include <GUIConstants.au3> GUICreate("My GUI Button"); will create a dialog box that when displayed is centered Opt("GUICoordMode",2) $Button_1 = GUICtrlCreateButton ("Run Notepad", 10, 30, 100) $Button_2 = GUICtrlCreateButton ( "Button Test", 0, -1) GUISetState () ; will display an dialog box with 2 button ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $Button_1 Run("notepad.exe") Case $msg = $Button_2 ShowMessage() EndSelect Wend Func ShowMessage() MsgBox(0, "Reporting ...", "You pressed 'Button Test'") EndFunc In general it's not a good idea to execute code in the while loop, just move it out into a function and call that only if a certain message event triggers. This code was checked and runs on 3.2.10.0 Just ask if you want more explanations/additions wim Edited February 2, 2008 by whim 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