bucky002 Posted February 17, 2006 Share Posted February 17, 2006 What's the code? Thanks. Link to comment Share on other sites More sharing options...
cppman Posted February 17, 2006 Share Posted February 17, 2006 choice 1 While 1 Wend choice 2 For $i = x to x next hope that helps you... Miva OS Project Link to comment Share on other sites More sharing options...
bucky002 Posted February 17, 2006 Author Share Posted February 17, 2006 So like this? 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") Wend Will it only repeat once? Link to comment Share on other sites More sharing options...
cppman Posted February 17, 2006 Share Posted February 17, 2006 (edited) yeah, like that. and no, it will repeat forever... if u want it to repeat once u would do: For $i = 1 to 2 Run("notepad.exe") WinWaitActive("Untitled - Notepad") Send("Heyheyheyheyheyheyheyheyhey.") WinClose("Untitled - Notepad") WinWaitActive("Notepad", "The text in the Untitled file has changed") Send("!n") Next Edited February 17, 2006 by CHRIS95219 Miva OS Project Link to comment Share on other sites More sharing options...
=sinister= Posted February 17, 2006 Share Posted February 17, 2006 (edited) Or $loop = 0 While $loop < 5 Run("notepad.exe") WinWaitActive("Untitled - Notepad") Send("Heyheyheyheyheyheyheyheyhey.") WinClose("Untitled - Notepad") WinWaitActive("Notepad", "The text in the Untitled file has changed") Send("!n") $loop = $loop + 1 Wend Edited February 17, 2006 by =sinister= Link to comment Share on other sites More sharing options...
cppman Posted February 17, 2006 Share Posted February 17, 2006 Or $loop = 0 While $loop < 5 Run("notepad.exe") WinWaitActive("Untitled - Notepad") Send("Heyheyheyheyheyheyheyheyhey.") WinClose("Untitled - Notepad") WinWaitActive("Notepad", "The text in the Untitled file has changed") Send("!n") $loop = loop + 1 Wend you forgot to put "$" before loop... $loop + 1. lol. just thought i'd point that out, so bucky does'nt get confused... $loop = 0 While $loop < 5 Run("notepad.exe") WinWaitActive("Untitled - Notepad") Send("Heyheyheyheyheyheyheyheyhey.") WinClose("Untitled - Notepad") WinWaitActive("Notepad", "The text in the Untitled file has changed") Send("!n") $loop = $loop + 1 Wend Miva OS Project Link to comment Share on other sites More sharing options...
bucky002 Posted February 17, 2006 Author Share Posted February 17, 2006 Lol, good I want it to reapeat forever thanks, but how do I stop it? Link to comment Share on other sites More sharing options...
herewasplato Posted February 17, 2006 Share Posted February 17, 2006 ...if u want it to repeat once u would do:For $i = 1 to 2For $i = 1 to 1...or no for/next loop at all... [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
cppman Posted February 17, 2006 Share Posted February 17, 2006 For $i = 1 to 1...or no for/next loop at all... but would'nt 1 to 1 loop it 0 times? which would mean it would'nt loop at all? Miva OS Project Link to comment Share on other sites More sharing options...
cppman Posted February 17, 2006 Share Posted February 17, 2006 Lol, good I want it to reapeat forever thanks, but how do I stop it?for the While/Wend loop you would do ExitLoop Miva OS Project Link to comment Share on other sites More sharing options...
bucky002 Posted February 17, 2006 Author Share Posted February 17, 2006 Like this? Loop Run("notepad.exe") WinWaitActive("Untitled - Notepad") Send("Heyheyheyheyheyheyheyheyhey.") WinClose("Untitled - Notepad") WinWaitActive("Notepad", "The text in the Untitled file has changed") Send("!n") Exit Thanks. Link to comment Share on other sites More sharing options...
cppman Posted February 17, 2006 Share Posted February 17, 2006 Like this? Loop Run("notepad.exe") WinWaitActive("Untitled - Notepad") Send("Heyheyheyheyheyheyheyheyhey.") WinClose("Untitled - Notepad") WinWaitActive("Notepad", "The text in the Untitled file has changed") Send("!n") Exit Thanks. 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... 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.. Miva OS Project Link to comment Share on other sites More sharing options...
bucky002 Posted February 17, 2006 Author Share Posted February 17, 2006 Okay I'll see if I can do it. Thank you. Link to comment Share on other sites More sharing options...
cppman Posted February 17, 2006 Share Posted February 17, 2006 no problem.... Miva OS Project Link to comment Share on other sites More sharing options...
bucky002 Posted February 17, 2006 Author Share Posted February 17, 2006 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... 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.. Hmm... This didn't work for me. It just stopped after the first time. 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... Thanks again. Link to comment Share on other sites More sharing options...
bucky002 Posted February 17, 2006 Author Share Posted February 17, 2006 Thanks for your help, but I have to get off. Thanks again I think I figured it out. Link to comment Share on other sites More sharing options...
herewasplato Posted February 17, 2006 Share Posted February 17, 2006 but would'nt 1 to 1 loop it 0 times? which would mean it would'nt loop at all?nope... just run the code that you wrote and see how many times it runs. :-) [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
cppman Posted February 17, 2006 Share Posted February 17, 2006 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 Miva OS Project Link to comment Share on other sites More sharing options...
cppman Posted February 17, 2006 Share Posted February 17, 2006 nope... just run the code that you wrote and see how many times it runs. :-)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... Miva OS Project Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 17, 2006 Moderators Share 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 = 1 not trying to argue, its just a bit mind boggeling...If that's mind boggeling ... look out!! ... just run the 2 loops below. For $i = 1 To 2 MsgBox(0, 'Test', $i) Next For $x = 1 To 1 MsgBox(0, 'Test2', $x) Next 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. 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