Jump to content
• Sign Up

# Loop time out?

## Recommended Posts

How can I put a time limit on loops?

I'm a newbie.Sorry if I don't reposed to your replays very fast.

#### Share this post

##### Share on other sites

Look at TimerInit() and TimerDiff(). You're question is broad, if you just want to know what functions you would probably use, I gave that to you. If you want someone to write it for you, you'll need to show what you did to try and use those 2 functions first.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

#### Share this post

##### Share on other sites

Ok so I looked them over and figer it should be something like this:

\$begin = TimerInit()

\$dif = TimerDiff(\$begin)

\$Value2 = PixelChecksum(249, 216, 249, 216)

While \$Value2 = PixelChecksum(249, 216, 249, 216)

Sleep(1000)

If \$Dif > 300000 Then Send("Exit")

WEnd

Or is that jsut F'ed up?

or more like this?

TimerInit()

TimerDiff(\$begin)

\$Value2 = PixelChecksum(249, 216, 249, 216)

While \$Value2 = PixelChecksum(249, 216, 249, 216)

Sleep(1000)

If \$Dif > 300000 Then Send("Exit")

WEnd

Edited by Orgins

I'm a newbie.Sorry if I don't reposed to your replays very fast.

#### Share this post

##### Share on other sites

Ok so I looked them over and figer it should be something like this:

I don't know why you want to send Exit on the end, but other then that, you're pretty close.

```Sleep(3000)
\$Begin = TimerInit()
\$Value2 = PixelChecksum(249, 216, 249, 216)

While \$Value2 = PixelChecksum(249, 216, 249, 216)
Sleep(1000)
TimerDiff(\$begin)
If \$Dif > 300000 Then Send("Exit");do you just want to exit?
WEnd```

Does that suit you needs better?

#### Share this post

##### Share on other sites

More like this:

```\$begin = TimerInit()

\$Value2 = PixelChecksum(249, 216, 249, 216)

While \$Value2 = PixelChecksum(249, 216, 249, 216)
Sleep(1000)
If TimerDiff(\$begin)/1000 > 300 Then Exitloop
WEnd
oÝ÷ Øhmºw^®ËZÜ!jÜ¨¹ªÞ¶¼¢hv"¶®¢Ý7éV¥¹í```
Edited by The Kandie Man

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

#### Share this post

##### Share on other sites

Perhaps you mean this:

```\$begin = TimerInit()

\$Value2 = PixelChecksum(249, 216, 249, 216)

While 1
\$Value2 = PixelChecksum(249, 216, 249, 216)
Sleep(1000)
If TimerDiff(\$begin)/1000 > 300 Then Exitloop
WEnd```
No, because that would redefine the checksum and make his script not work

He got his script from another thread, and he wanted to have a script wait to do something until that particular pixel changed, hes now just trying to put the 300 second timeout if nothing changes for 300 seconds

#### Share this post

##### Share on other sites

I like you guys people actually help here.

Thxs.

Edit* Truns out TimerInit()/TimerDiff doesn't like loops. Guess it uses the old dif. Anyways I figerd how it fix it.

\$x = 0

Do

\$x = \$x + 1

\$begin = TimerInit()

\$Value2 = PixelChecksum(249, 216, 249, 216)

While \$Value2 = PixelChecksum(249, 216, 249, 216)

Sleep(1000)

If TimerDiff(\$begin)/1000 > 300 Then Exitloop

WEnd

Until \$x = 1

Edited by Orgins

I'm a newbie.Sorry if I don't reposed to your replays very fast.

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

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...