blessthefall Posted June 6, 2008 Share Posted June 6, 2008 I'm not completely new to AutoIt, but I'm by no means a veteran. I've been wondering how to do this for months now; usually when I have problems with AutoIt I consult the help file or google. Thus far I've still been at a loss. I'm trying to figure out how to end a loop when a certain condition (unrelated to the loop) changes. This is essentially a dumbed down example of what I'm trying to do: --------------------------------------------------------------------- $checksum = PixelChecksum(x1,y1, x2,y2) While $checksum = PixelChecksum(x1,y1, x2,y2) $abc = 0 Do Send ("abcgefghijklmnopqrstuvwxyz") $abc = $abc + 1 Until $abc = 100 WEnd ---------------------------------------------------------------------- *The coordinates aren't important. What I want to do is halt the loop when the condition (my PixelChecksum) changes even if the loop hasn't fully completed. Simply checking the PixelChecksum after each " Send ("abcgefghijklmnopqrstuvwxyz") " doesn't work for me because if the pixel area changes at "a" the loop won't be halted until after "z" has been sent. Also what I'm doing is much longer and complicated than that. I just want a way to halt it instantly. Hope I explained this well enough =/ Link to comment Share on other sites More sharing options...
gulthaw Posted June 6, 2008 Share Posted June 6, 2008 I've checked the help file and find the ExitLoop command. $checksum = PixelChecksum(x1,y1, x2,y2) While $checksum = PixelChecksum(x1,y1, x2,y2) $abc = 0 Do Send ("abcgefghijklmnopqrstuvwxyz") $abc = $abc + 1 Until $abc = 100 if $abc = 100 then ExitLoop WEnd It seems to be what you need Link to comment Share on other sites More sharing options...
k3v Posted June 6, 2008 Share Posted June 6, 2008 (edited) "a" through "z" are ascii values 97 through 122. So... $checksum = PixelChecksum(x1,y1, x2,y2) While $checksum = PixelChecksum(x1,y1, x2,y2) $abc = 0 Do for $i = 97 to 122 send("{ASC " & $i & "}") $abc = $abc + 1 if Not (PixelChecksum(x1,y1, x2,y2) = $checksum) then exitloop next Until $abc = 100 WEnd or something similar. Does that help? Edited June 6, 2008 by k3v Link to comment Share on other sites More sharing options...
blessthefall Posted June 6, 2008 Author Share Posted June 6, 2008 I've checked the help file and find the ExitLoop command. $checksum = PixelChecksum(x1,y1, x2,y2) While $checksum = PixelChecksum(x1,y1, x2,y2) $abc = 0 Do Send ("abcgefghijklmnopqrstuvwxyz") $abc = $abc + 1 Until $abc = 100 if $abc = 100 then ExitLoop WEnd It seems to be what you need I think you may have misunderstood my problem. The way this is set up, the script will execute ' Send ("abc...") ' 100 times regardless of what happens in my PixelChecksum area. It isn't until after the Do loop is completed that the script goes back and checks the PixelChecksum area. Link to comment Share on other sites More sharing options...
blessthefall Posted June 6, 2008 Author Share Posted June 6, 2008 "a" through "z" are ascii values 97 through 122. So... $checksum = PixelChecksum(x1,y1, x2,y2) While $checksum = PixelChecksum(x1,y1, x2,y2) $abc = 0 Do for $i = 97 to 122 send("{ASC " & $i & "}") $abc = $abc + 1 if Not (PixelChecksum(x1,y1, x2,y2) = $checksum) then exitloop next Until $abc = 100 WEnd or something similar. Does that help? Actually this is closer to what I was looking for, however I think the solution is very situational (it only applies to this particular script). What if instead of " Send ("abc...") " I was having it execute a long series of complicated commands. All I want to do is to stop whatever it's doing inside of the While <-> WEnd the instant something changes in my pixel field. It's irrelevant what I'm trying to make the script do, I want to focus more on what I'm trying to get it not to do. Link to comment Share on other sites More sharing options...
gulthaw Posted June 6, 2008 Share Posted June 6, 2008 (edited) All I want to do is to stop whatever it's doing inside of the While <-> WEnd the instant something changes in my pixel field. It's irrelevant what I'm trying to make the script do, I want to focus more on what I'm trying to get it not to do.I think the problem here is the repeat inside the while.ExitLoop seems to be what you need Terminate a While/Do/For loop. but only works with While, Do and For loops.Edit: If you can transform the repeat into a do-until that should work (if i understand it correctly). Edited June 6, 2008 by gulthaw Link to comment Share on other sites More sharing options...
k3v Posted June 6, 2008 Share Posted June 6, 2008 In that case, one would need more information about the long series of commands you plan to execute. Can you provide an example that more closely resembles your intentions? Link to comment Share on other sites More sharing options...
Bert Posted June 6, 2008 Share Posted June 6, 2008 Use case statements instead of a do - until in your loop. The Vollatran project  My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
blessthefall Posted June 6, 2008 Author Share Posted June 6, 2008 In that case, one would need more information about the long series of commands you plan to execute. Can you provide an example that more closely resembles your intentions?I actually plan on using this for a number of different things. I'm experimenting with bots for games.The best way I can describe what I want is to leave ' Send ("abcdefghijklmnopqrstuvqxyz") ' unchanged. Now let's say that something changed in my pixel field between "d" and "e" being sent. I want the script to have only sent "abcd" nothing else because something changed at that point. I'm looking for a universal way to do this, regardless of what's in While <-> WEnd.Maybe it's not possible? Link to comment Share on other sites More sharing options...
blessthefall Posted June 6, 2008 Author Share Posted June 6, 2008 Use case statements instead of a do - until in your loop.I've tried a number of different things... nothing seemed to work for me. I'm not extremely experienced with AutoIt... That's why I came here =). $checksum = PixelChecksum(x1,y1, x2,y2)While $checksum = PixelChecksum(x1,y1, x2,y2)$abc = 0While $abc < 100Send ("abcgefghijklmnopqrstuvwxyz")$abc = $abc + 1WEndWEndI suppose this is what you were suggesting, tho this doesn't fix my problem. Link to comment Share on other sites More sharing options...
k3v Posted June 6, 2008 Share Posted June 6, 2008 As it stands, your Send() command is a single instruction that will be completed before any subsequent comparisons are made. That being said, I'm afraid I'm out of "conventional" ideas... (a thought I had briefly is WAY outside the box, and could do more to create more problems before resolving yours) Link to comment Share on other sites More sharing options...
Bert Posted June 6, 2008 Share Posted June 6, 2008 no, what I had in mind is somehting like this: while 1 Select case $abc < 100 ;do something case $abc > 100 ;do something case Else ;do something EndSelect WEnd The Vollatran project  My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
blessthefall Posted June 6, 2008 Author Share Posted June 6, 2008 As it stands, your Send() command is a single instruction that will be completed before any subsequent comparisons are made. That being said, I'm afraid I'm out of "conventional" ideas... (a thought I had briefly is WAY outside the box, and could do more to create more problems before resolving yours)I figured that it might come down to that =(. As far as something unconventional, would it be possible to have two different scripts running in conjunction with each other? When one detects a change, I could have it halt the other script.^^^ - Something like that viable?Btw I really appreciate your help. Link to comment Share on other sites More sharing options...
aNewLyfe Posted June 6, 2008 Share Posted June 6, 2008 (edited) as i see and understand you have to change checksum to exitloop $checksum = PixelChecksum(x1,y1, x2,y2) While $checksum = PixelChecksum(x1,y1, x2,y2) $abc = 0 Do Send ("abcgefghijklmnopqrstuvwxyz") $abc = $abc + 1 Until $abc = 100 WEnd while statement will continue cuz $checksum = PixelChecksum(x1,y1, x2,y2) still same. you have to stop this command to exit loop. or try to insert $checksum = "" after until, if i understand you correctly, it will work Edited June 6, 2008 by mistakilla  ~ Every Living Thing is a Code Snippet of World Application ~ Link to comment Share on other sites More sharing options...
blessthefall Posted June 6, 2008 Author Share Posted June 6, 2008 no, what I had in mind is somehting like this: while 1 Select case $abc < 100 ;do something case $abc > 100 ;do something case Else ;do something EndSelect WEnd Ah I'll have to read up on it a bit more, I'm not familiar with this as I've not used them before. Might be my solution but at this point I'm really not sure. Link to comment Share on other sites More sharing options...
k3v Posted June 6, 2008 Share Posted June 6, 2008 As far as something unconventional, would it be possible to have two different scripts running in conjunction with each other? When one detects a change, I could have it halt the other script. Kind-of... If your Send() command was an executable by itslef, the you could launch it instead of running Send() from your script... that way, your script would continue to process after launching it... when the desired contition occurs, do something like activate another window... (thing is, the Send() command will complete no matter what... but activating another window will prevent the remainder of the characters from being sent to their original destination.) $checksum = PixelChecksum(x1,y1, x2,y2) While $checksum = PixelChecksum(x1,y1, x2,y2) $abc = 0 Do run("sendstuff.exe") $abc = $abc + 1 if Not (PixelChecksum(x1,y1, x2,y2) = $checksum) then winactivate("someotherwindow") exitloop endif Until $abc = 100 WEnd Possible timing issues here, and you may not wish to take priority away from your main window just to break the Send() process. Link to comment Share on other sites More sharing options...
k3v Posted June 6, 2008 Share Posted June 6, 2008 (edited) Woops... (ended up replying twice... sorry folks!) Edited June 6, 2008 by k3v Link to comment Share on other sites More sharing options...
k3v Posted June 6, 2008 Share Posted June 6, 2008 (edited) (man... thought I was going crazy... maybe I am... ) just figured out there is more than one page... really sorry, people! (can anyone tell me how to delete all these duplicates?) Edited June 6, 2008 by k3v Link to comment Share on other sites More sharing options...
blessthefall Posted June 6, 2008 Author Share Posted June 6, 2008 Kind-of... If your Send() command was an executable by itslef, the you could launch it instead of running Send() from your script... that way, your script would continue to process after launching it... when the desired contition occurs, do something like activate another window... (thing is, the Send() command will complete no matter what... but activating another window will prevent the remainder of the characters from being sent to their original destination.) $checksum = PixelChecksum(x1,y1, x2,y2) While $checksum = PixelChecksum(x1,y1, x2,y2) $abc = 0 Do run("sendstuff.exe") $abc = $abc + 1 if Not (PixelChecksum(x1,y1, x2,y2) = $checksum) then winactivate("someotherwindow") exitloop endif Until $abc = 100 WEnd Possible timing issues here, and you may not wish to take priority away from your main window just to break the Send() process. But instead of opening "someotherwindow" could i just replace it with a command that closes "sendstuff.exe"? Link to comment Share on other sites More sharing options...
k3v Posted June 6, 2008 Share Posted June 6, 2008 Sure... get the PID when you launch it, and kill the PID when the condition occurs... But I've not researched this, so you may need to check the help file for doing all that. Or maybe someone here has some quick pointers...? 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