Valik Posted February 17, 2006 Posted February 17, 2006 i don't get it...would'nt it be logical for 1 to 2 make it loop once?because 2-1 = 1not trying to argue, its just a bit mind boggeling...I suggest you spend less time guessing and more time actually testing and trying to understand how For...Next works.Hint: It's called "To" not "Almost To".
herewasplato Posted February 17, 2006 Posted February 17, 2006 (edited) @CHRIS95219, I'm really not pickin' on ya... but how about running the code before you post it. but the ExitLoop should be in a function like:while 1 If _isPressed("01") then MouseClicked() else ;; endif wend Func MouseClicked() MsgBox(0, "", "") ExitLoop EndFunc np..Running that code will get you this:ExitLoop Error: "ExitLoop/ContinueLoop" statements only valid from inside a For/Do/While loop....and this code:nope... while 1 Run("notepad.exe") WinWaitActive("Untitled - Notepad") Send("Heyheyheyheyheyheyheyheyhey.") WinClose("Untitled - Notepad") WinWaitActive("Notepad", "The text in the Untitled file has changed") Send("!n") ExitLoop wend ;then whatever code you want here......does the same as:Run("notepad.exe") WinWaitActive("Untitled - Notepad") Send("Heyheyheyheyheyheyheyheyhey.") WinClose("Untitled - Notepad") WinWaitActive("Notepad", "The text in the Untitled file has changed") Send("!n") ;then whatever code you want here... No, you do not need to have ExitLoop in a function... you need ExitLoop where it is needed, like when a condition is met - then ExitLoop. There is no ExitLoop in the function in the sample code that you posted:yeah, u need to have the exit loop in a function... here is an example.. with a GUI and stuff. #include <GuiConstants.au3>;Functions needed for most GUI Code GuiCreate("Your GUI", 472, 188);Create GUI Window with the width of 472 and height of 188 $Button_1 = GuiCtrlCreateButton("Exit", 10, 130, 130, 50);Button_1 is the Exit Button $Button_2 = GuiCtrlCreateButton("Execute Script", 250, 100, 210, 80); Button_2 is the Execute Script function GuiSetState() While 1;your LOOP $msg = GuiGetMsg();retrieves the button or control that was pressed Select; starts a case statement Case $msg = $GUI_EVENT_CLOSE;case statement, its like an if statement but better when you have alot of statements ExitLoop; If the program is exited it will exit the loop. Case $msg = $Button_1 ExitLoop;Exits the Loop Case $msg = $Button_2 ExecuteScript(); goes to the Execute Script function EndSelect; ends the case statements WEnd Func ExecuteScript();Creats the Execute Script Function ;Your Code Run("notepad.exe") WinWaitActive("Untitled - Notepad") Send("Heyheyheyheyheyheyheyheyhey.") WinClose("Untitled - Notepad") WinWaitActive("Notepad", "The text in the Untitled file has changed") Send("!n") EndFunc...but it does run :-) i don't get it... would'nt it be logical for 1 to 2 make it loop once? because 2-1 = 1 not trying to argue, its just a bit mind boggeling...From the help file:The For loop terminates when the value of variable exceeds the stop threshold.The first time thru the loop $i = 1. The next time thru the loop $i = 2 and the script jumps to the next and continues with the rest of your code. ...hope this helps... Edited February 17, 2006 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size]
Moderators SmOke_N Posted February 17, 2006 Moderators Posted February 17, 2006 I suggest you spend less time guessing and more time actually testing and trying to understand how For...Next works.Hint: It's called "To" not "Almost To". ... Oh damn, I spit my soda all over the monitor!! Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
cppman Posted February 17, 2006 Posted February 17, 2006 i know how for-next loops work... and i know that for $i = 1 to 1 loops once... i was just saying... and yeah, i did'nt meant to put ExitLoop in their i meant to just put Exit... and for tyhe first script where the Exit loop is inside the While statement, i was just pointing something out.... gosh! lol. Miva OS Project
herewasplato Posted February 17, 2006 Posted February 17, 2006 ...gosh! lolGlad that you can laugh it off. You caught a lot of ..... somethin' there.The other two posts came in while I was writing my rather long post. I should have deleted that post once I saw the "corrections" from others... but I would still suggest that you run the code you post. Just don't hold me to that :-) as I do not always test the code that I post and at times, I post from a system w/o AutoIt3 installed....hang in there... [size="1"][font="Arial"].[u].[/u][/font][/size]
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