adrian1386 Posted January 2, 2006 Share Posted January 2, 2006 Ok. Someone told me on here that I have to use While WEnd for proper loops and not restart the script when I want to loop since its giving me overstack errors. However, when i tried to rewrite my script I ran into tons of problems. Basicly , the example in the autoit help file says "If the expression is true the following statements up to the WEnd statement are executed. This loop continues until the expression is false.". The example makes sense however, the way I tried to do it which Im guessing I did not properly is the "While 1 WEnd" that I have been seeing in some example scripts on here and other places. Most the time the script could not find the matching While statements for WEnd etc. Spent couple hours trying to rewrite and rewrite but could not get it to work properly. I'd appreciate it a lot if someone could rewrite my script so that it would work the same but loops properly. Here it is, and thanks in advance.WinActivate("program", "")Sleep(3000)main()Func main()$health = PixelGetColor (129,68) If $health = 238080 Then Send("{TAB}")Else Sleep(1000) main()EndIF$target = PixelGetColor (92,103)If $target = 10132890 Then Sleep(1000)Else main()EndIf$tofar = PixelGetColor (447,51)If $tofar = 3276800 Then Send("{TAB}") main()Else Sleep(1000)EndIf Send("7") Sleep(3000) Send("=") Sleep(1000) $i = 0 While $i <= 2 Send("4") Sleep(2100) Send("5") Sleep(2100) Send("6") Sleep(2100) Send("7") Sleep(2100) Send("8") Sleep(2100) $i = $i + 1 WEndSleep(1000)Call("main")EndFunc Link to comment Share on other sites More sharing options...
Oxin8 Posted January 2, 2006 Share Posted January 2, 2006 (edited) This should work. I contained the entire function in one big infinite While loop and use ContinueLoop when you want it to go to the start. expandcollapse popupWinActivate("program", "") Sleep(3000) main() Func main() While 1 $health = PixelGetColor (129,68) If $health = 238080 Then Send("{TAB}") Else Sleep(1000) ContinueLoop EndIF $target = PixelGetColor (92,103) If $target = 10132890 Then Sleep(1000) Else ContinueLoop EndIf $tofar = PixelGetColor (447,51) If $tofar = 3276800 Then Send("{TAB}") ContinueLoop Else Sleep(1000) EndIf Send("7") Sleep(3000) Send("=") Sleep(1000) $i = 0 While $i <= 2 Send("4") Sleep(2100) Send("5") Sleep(2100) Send("6") Sleep(2100) Send("7") Sleep(2100) Send("8") Sleep(2100) $i = $i + 1 WEnd Sleep(1000) WEnd EndFunc Edited January 2, 2006 by Larry ~My Scripts~ *********_XInput UDF for Xbox 360 ControllerSprayPaint_MouseMovePlus Link to comment Share on other sites More sharing options...
w0uter Posted January 2, 2006 Share Posted January 2, 2006 dont use call. My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
adrian1386 Posted January 2, 2006 Author Share Posted January 2, 2006 For some reason that script doenst work, Its running and no errors but it doesn't do what its told and I double checked the cordinates and dec colors. :/The example that comes with AutoIT help file makes total sense to me$i = 0While $i <= 10 MsgBox(0, "Value of $i is:", $i) $i = $i + 1WEndWhen the expression becomes false it will stop looping. I can grasp this example and concept.I dont however understand how the While 1 script operates. I have very minimal knowlege of this stuff as you can see, infact I only picked it up 2 days ago for the first time. (Did some simple VB 2 years ago in Computer Tech Class). I do appreciate all the help so far With your help I'll be able to finish my script Link to comment Share on other sites More sharing options...
adrian1386 Posted January 2, 2006 Author Share Posted January 2, 2006 Ok thank you I got the script to work, it appears my IQ is very low :/ Changed some settings in the Get Info prog. Got it to work but still would like an explanation of using While 1 WEnd and how they work. 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