brad25 Posted December 8, 2010 Share Posted December 8, 2010 Hi everyone, like the topic says but im using a button to exit the program but once it starts the loop it will not close. any help would be great. expandcollapse popupfunc test() while 1 $scoord = PixelSearch( 727, 100, 953, 401, 0x9e9e00) if not @error Then MouseMove ( $scoord[0], $scoord[1]) sleep(1000) MouseMove ( $scoord[0]+40, $scoord[1]) MouseClick("right") MouseMove ( $scoord[0]+70, $scoord[1]) MouseClick("left") sleep(1000) MouseMove(426, 396) EndIf WEnd EndFunc func exit1() if $nMsg=$button2 then Exit EndFunc #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Jumper = GUICreate("Jumper", 188, 81, 409, 433) $Button1 = GUICtrlCreateButton("Start", 16, 40, 73, 25) $Button2 = GUICtrlCreateButton("Exit", 96, 41, 73, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() if $nMsg=$button1 then test() if $nMsg=$button2 then exit1() WEnd Link to comment Share on other sites More sharing options...
JohnOne Posted December 8, 2010 Share Posted December 8, 2010 If the right condition are met for you, use ExitLoop keyword. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Thlitmi Posted December 8, 2010 Share Posted December 8, 2010 Add this $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE EndSwitch Clicing X will exit loop and program Link to comment Share on other sites More sharing options...
brad25 Posted December 8, 2010 Author Share Posted December 8, 2010 Add this $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE EndSwitch Clicing X will exit loop and program that doesnt work either Link to comment Share on other sites More sharing options...
Thlitmi Posted December 8, 2010 Share Posted December 8, 2010 (edited) How did you add it ? Show the code. Edited December 8, 2010 by Thlitmi Link to comment Share on other sites More sharing options...
JohnOne Posted December 8, 2010 Share Posted December 8, 2010 that doesnt work eitherWell you dont have a GUI thats why.When you say "Either", do you mean exitloop is not exiting the while loop? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Varian Posted December 8, 2010 Share Posted December 8, 2010 (edited) The Exit button works if you click it first. If you click the Start button, the script is stuck in an endless loop. That's why clicking on the Exit button after clicking on the Start button does no good. You cannot break into the loop. Consider using an ExitLoop or Return after the MouseMoves have finished or if there is an @errorFunc test() While 1 $Scoord = PixelSearch(727, 100, 953, 401, 0x9e9e00) If Not @error Then MouseMove($Scoord[0], $Scoord[1]) Sleep(1000) MouseMove($Scoord[0] + 40, $Scoord[1]) MouseClick("right") MouseMove($Scoord[0] + 70, $Scoord[1]) MouseClick("left") Sleep(1000) MouseMove(426, 396) Return Else Return EndIf WEnd EndFunc ;==>testFYI, you just need Exit in your Exit1() function. Technically $nMsg and $Button2 are not Global variables and you did not pass them to the function.Func exit1() Exit EndFunc ;==>exit1 Edited December 8, 2010 by Varian Link to comment Share on other sites More sharing options...
MvGulik Posted December 8, 2010 Share Posted December 8, 2010 "How to exit A endless while loop"You can't! ... It would not be a endless loop anymore. (o.O) *hick* "Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions.""The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014) "Believing what you know ain't so" ... Knock Knock ... 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