Sign in to follow this  
Followers 0
jonathan2133

Using while loops with if statments?

2 posts in this topic

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?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

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