brad25 0 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 Share this post Link to post Share on other sites
JohnOne 1,603 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. Share this post Link to post Share on other sites
Thlitmi 0 Posted December 8, 2010 Add this $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE EndSwitch Clicing X will exit loop and program Share this post Link to post Share on other sites
brad25 0 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 Share this post Link to post Share on other sites
Thlitmi 0 Posted December 8, 2010 (edited) How did you add it ? Show the code. Edited December 8, 2010 by Thlitmi Share this post Link to post Share on other sites
JohnOne 1,603 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. Share this post Link to post Share on other sites
Varian 8 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 Share this post Link to post Share on other sites
MvGulik 86 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 ... Share this post Link to post Share on other sites