Jump to content

Looping


Recommended Posts

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
Link to comment
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.

Link to comment
Share on other sites

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
Link to comment
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...

Link to comment
Share on other sites

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

Link to comment
Share on other sites

You may want to review this code pice

While $checksum = PixelChecksum(183,262,234,263)
  Sleep(100)
WEnd
Edited by Uten
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...