Jump to content

Using while loops with if statments?


Recommended Posts

i have the following code:

$checksum = PixelChecksum(235, 432, 241, 446)

While $checksum = PixelChecksum(235, 432, 241, 446)

Sleep(100)

WEnd

It waits until the pixels in the selected area changes then continues. The problem is im using this for a macro on a website and sometimes the server goes faster or slower than expected, and the pixels it finds to watch to change are already changed. This is not a problem 90% of the time, but that remaining 10% is a pain. How can i make it continue after a set amount of seconds has gone bye? I was thinking somthing along these lines:

$a = 100000

$checksum = PixelChecksum(235, 432, 241, 446)

While $checksum = PixelChecksum(235, 432, 241, 446)

$a = $a - 1

if $a = 1 (this is where i would use goto but its gone... i loved goto and totally object to its removal... but thats a new rant all together)

Sleep(100)

WEnd

I cant use goto and i tried a few other things but it seems the if statment will stop the while statment. How do i get around this?

Link to comment
Share on other sites

Maybe like this

$begin = TimerInit()
$checksum = PixelChecksum(235, 432, 241, 446)

While $checksum = PixelChecksum(235, 432, 241, 446)
$dif = TimerDiff($begin)
If $dif > 3000 Then ExitLoop
Sleep(100)
WEnd

Note; 1000 = 1 second

8)

Edited by Valuater

NEWHeader1.png

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...