makeshift 0 Posted October 2, 2007 Hi all, I need a bit of help with looping, my script seems to loop...but very slowly, when it gets to the last command and is supposed to loop, it takes AGES to complete the loop and do the script again. Could anybody please help me? Here's my script: While 1 Sleep(5000) MouseClick("left", 206, 312, 1, 0) Sleep(500) MouseClick("left", 206, 312, 1, 0) Sleep(1000) $checksum = PixelChecksum(183,262,234,263) While $checksum = PixelChecksum(183,262,234,263) Sleep(100) WEnd Sleep(100) MouseClick("left", 206, 312, 1, 0) Sleep(50) MouseClick("left", 206, 312, 1, 0) Sleep(5000) MouseClick("left", 206, 312, 1, 0) Sleep(50) MouseClick("left", 206, 312, 1, 0) WEnd Exit Share this post Link to post Share on other sites
McGod 0 Posted October 2, 2007 It's coded to sleep for 5 seconds each loop. Sleep(5000) While 1 MouseClick("left", 206, 312, 1, 0) Sleep(500) MouseClick("left", 206, 312, 1, 0) Sleep(1000) $checksum = PixelChecksum(183,262,234,263) While $checksum = PixelChecksum(183,262,234,263) Sleep(100) WEnd Sleep(100) MouseClick("left", 206, 312, 1, 0) Sleep(50) MouseClick("left", 206, 312, 1, 0) Sleep(5000) MouseClick("left", 206, 312, 1, 0) Sleep(50) MouseClick("left", 206, 312, 1, 0) WEnd Exit That might fix it, it sleeps 5 seconds once. [indent][center][u]Formerly Chip[/u][/center]~UDFs~[/indent][u]IRC.au3 - Allows you to connect to IRC ServersINetCon.au3 - Connects/Disconnects/Check Status of InternetHardware Key - Creates a unique hardware hashScriptComm - Allows you to communicate between scripts using WM_COPYDATA[/u][indent]~Programs~[/indent][indent]SimonAu3ForumsIRC Bot~Web Site~Web Autoit Example[/indent][indent][b][/b][/indent][u][/u] Share this post Link to post Share on other sites
Paulie 26 Posted October 2, 2007 (edited) well, your script has many sleeps of 5000 milliseconds (5 secs), specifically, the one at the very beginning. I ran the script and i didn't see anything that i didn't expect to see. With more detailed intructions in regards to what you want it to do, it will likely be possible to adjust it to however it needs to be. Edited October 2, 2007 by Paulie Share this post Link to post Share on other sites
makeshift 0 Posted October 3, 2007 Well actually, i intended to put that 5 seconds of sleep there, to account for the ultra-lag after the last command ( It's for a game, i know, it's pretty basic, but so is the game ) But it loops twice...then it takes like 5 minutes to loop again...and 10 mins... Share this post Link to post Share on other sites
Blue_Drache 260 Posted October 3, 2007 (edited) Hardcoded waits are usually the last resort, since lag can, and does, change. Is there something on the screen that's a constant colour until said lag vanishes? If so, use a soft wait in an infinate loop (with a maximum to bail out on). Soft wait example: ; Loop approximately 5 seconds while we wait for a pixel at 100,100 to change to pure red. $intCount = 0 While $intCount < 500 $intCount += 1 Sleep(10) $intColour = PixelGetColor(100, 100) If Hex($intColour) = 0xFF0000 Then ExitLoop WEnd Edit: Tidied script. Edited October 3, 2007 by Blue_Drache Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Share this post Link to post Share on other sites
Uten 9 Posted October 3, 2007 (edited) You may want to review this code pice While $checksum = PixelChecksum(183,262,234,263) Sleep(100) WEnd Edited October 3, 2007 by Uten Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling Share this post Link to post Share on other sites
makeshift 0 Posted October 3, 2007 Ah, it works now, may of just been problems on my machine, but thanks for the code anyway. I'll definitely use it. Share this post Link to post Share on other sites