Sign in to follow this  
Followers 0
makeshift

Looping

7 posts in this topic

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



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.

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 by Paulie

Share this post


Link to post
Share on other sites

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

#5 ·  Posted (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 by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

You may want to review this code pice

While $checksum = PixelChecksum(183,262,234,263)
  Sleep(100)
WEnd
Edited by Uten

Share this post


Link to post
Share on other sites

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

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0