# ToolTip(Sleep(30000)) How to Display a Counting SleepTime ToolTip..?

## Recommended Posts

ToolTip(Sleep(30000))

How can I make a ToolTip function work with a Sleep function so it counts up from 0->30 showing the counting in a tooltip..??

##### Share on other sites

If you want to display actual seconds, then something like this might do you:

```Dim \$x
\$Timer = TimerInit()
While \$x < 30
\$x = Int(TimerDiff(\$Timer)/1000)
Tooltip(\$x,100,100)
Wend```
Edited by Spiff59

##### Share on other sites

thanks, it works, but it seems a lil too CPU intensive..??

is there any other ways that doesnt make the CPU go up 40% when running that code.??

##### Share on other sites

```\$x =0
\$Timer = TimerInit()
While \$x < 30
Sleep(1)
\$x = Int(TimerDiff(\$Timer)/1000)
Tooltip(\$x,100,100)
Wend```

Better?

##### Share on other sites

```\$x =0
\$Timer = TimerInit()
While \$x < 30
Sleep(1)
\$x = Int(TimerDiff(\$Timer)/1000)
Tooltip(\$x,100,100)
Wend```

Better?

Just a FYI, the minimum sleep with AutoIt's Standard Sleep() function is 10ms, so Using Sleep(1) through Sleep(9) is the same as Sleep(10). (Just in case you weren't aware)

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 on other sites

how could i turn all that code into a Function so i could call it like _SleepTimerToolTip(#) and instead of putting the # of seconds in the While \$x < 30 put it inside the _SleepTimerToolTip(#)

get what im sayin..??

how would ya do this..??

##### Share on other sites

how could i turn all that code into a Function so i could call it like _SleepTimerToolTip(#) and instead of putting the # of seconds in the While \$x < 30 put it inside the _SleepTimerToolTip(#)

get what im sayin..??

how would ya do this..??

I would prefer it in a countdown manner. Then you know, how long it takes to the end.

Here a sample:

```_SleepTimerToolTip(5)

Func _SleepTimerToolTip(\$iSeconds)
While \$iSeconds
ToolTip(\$iSeconds)
\$iSeconds -= 1
Sleep(1000)
WEnd
ToolTip("")
EndFunc   ;==>_SleepTimerToolTip```

My UDFs, Abbrevs and Snippets
If you like my post, just click the like button

## Create an account

Register a new account

×

• Wiki

• Back

• Git