Sign in to follow this  
Followers 0
shay

how to create counter display

10 posts in this topic

Hi all

i have a simple script that sleep for long time (up to 12h)than preform action,

i like to add a display for the counter so i`ll see the sleep time,

i didn't find any way to display the sleep time.

any idea? :D


"If the facts don't fit the theory, change the facts." Albert Einstein

Share this post


Link to post
Share on other sites



Hi all

i have a simple script that sleep for long time (up to 12h)than preform action,

i like to add a display for the counter so i`ll see the sleep time,

i didn't find any way to display the sleep time.

any idea? :D

$begin = TimerInit()
;Do your waitting here
while 1  ; loop
$dif = TimerDiff($begin) ; check the time, display it.
wend
MsgBox(0,"Time Difference",$dif);Now this is the end of the script.

Share this post


Link to post
Share on other sites

$begin = TimerInit()
;Do your waitting here
while 1  ; loop
$dif = TimerDiff($begin) ; check the time, display it.
wend
MsgBox(0,"Time Difference",$dif);Now this is the end of the script.

PuppyPlanet was trying to make a quick score again and totally fucked up on the example.

As for the actual answer to the question, you can use something like this:

; Calls the sleep and display function with a 5 second delay
_SleepAndDisplay(5000)

Func _SleepAndDisplay($sleepTime, $checkEveryMS = 100) ; $sleepTime determines how long to sleep, $checkEveryMS determines how often should be checked (in example: 100ms checks 10 times per second (1000/100 = 10))
    $timeStamp = TimerInit() ; Store the time we started to sleep in a variable
    
    while 1 ; Continously check how much time has elapsed and display it
        $timeDiff = TimerDiff($timeStamp) ; Check how much time has elapsed since we started sleeping
        if ($timeDiff > $sleepTime) Then ; If the time for sleeping has passed, we can go out of the loop
            ExitLoop ; Exit the loop and go to the end of the function
        EndIf
        ToolTip(@ScriptName & ": " & Round($timeDiff/1000) & "s of waiting have elapsed.", 0, 0) ; Displays a message with the time that has been waited in seconds
        Sleep($checkEveryMS) ; Wait a while before we do the next step. If we omit this step then CPU message will skyrocket.
    wend
    
    ToolTip("") ; Removes the ToolTip from the screen.
    
    Return ; Exits the function
EndFunc

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

PuppyPlanet was trying to make a quick score again and totally fucked up on the example.

As for the actual answer to the question, you can use something like this:

; Calls the sleep and display function with a 5 second delay
_SleepAndDisplay(5000)

Func _SleepAndDisplay($sleepTime, $checkEveryMS = 100) ; $sleepTime determines how long to sleep, $checkEveryMS determines how often should be checked (in example: 100ms checks 10 times per second (1000/100 = 10))
    $timeStamp = TimerInit() ; Store the time we started to sleep in a variable
    
    while 1 ; Continously check how much time has elapsed and display it
        $timeDiff = TimerDiff($timeStamp) ; Check how much time has elapsed since we started sleeping
        if ($timeDiff > $sleepTime) Then ; If the time for sleeping has passed, we can go out of the loop
            ExitLoop ; Exit the loop and go to the end of the function
        EndIf
        ToolTip(@ScriptName & ": " & Round($timeDiff/1000) & "s of waiting have elapsed.", 0, 0) ; Displays a message with the time that has been waited in seconds
        Sleep($checkEveryMS) ; Wait a while before we do the next step. If we omit this step then CPU message will skyrocket.
    wend
    
    ToolTip("") ; Removes the ToolTip from the screen.
    
    Return ; Exits the function
EndFunc

Okay, I am going if you don't want me here, bye everyone.

Ban me. Do what ever you want just can't stand your f-ing face anymore.

OUT!

Edit: My last word is. The only reason that you write this script is because I posted a bad script and you just want to call me a PuppyPlanet. You mom is one go and have a look.

Edited by WolfWorld

Share this post


Link to post
Share on other sites

As for the actual answer to the question, you can use something like this:

:D

wow this is cool use for the "ToolTip" function,

i`ll embedded this in my code

thenx you all for the fast replay,


"If the facts don't fit the theory, change the facts." Albert Einstein

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

:D

wow this is cool use for the "ToolTip" function,

i`ll embedded this in my code

thenx you all for the fast replay,

You're more than welcome, shay.

If you have any more questions, don't hesitate to ask.

Edited by Manadar

Share this post


Link to post
Share on other sites

What is a puppyplanet ?!

Share this post


Link to post
Share on other sites

PuppyPlanet was trying to make a quick score again and totally fucked up on the example.

As for the actual answer to the question, you can use something like this:

; Calls the sleep and display function with a 5 second delay
_SleepAndDisplay(5000)

Func _SleepAndDisplay($sleepTime, $checkEveryMS = 100) ; $sleepTime determines how long to sleep, $checkEveryMS determines how often should be checked (in example: 100ms checks 10 times per second (1000/100 = 10))
    $timeStamp = TimerInit() ; Store the time we started to sleep in a variable
    
    while 1 ; Continously check how much time has elapsed and display it
        $timeDiff = TimerDiff($timeStamp) ; Check how much time has elapsed since we started sleeping
        if ($timeDiff > $sleepTime) Then ; If the time for sleeping has passed, we can go out of the loop
            ExitLoop ; Exit the loop and go to the end of the function
        EndIf
        ToolTip(@ScriptName & ": " & Round($timeDiff/1000) & "s of waiting have elapsed.", 0, 0) ; Displays a message with the time that has been waited in seconds
        Sleep($checkEveryMS) ; Wait a while before we do the next step. If we omit this step then CPU message will skyrocket.
    wend
    
    ToolTip("") ; Removes the ToolTip from the screen.
    
    Return ; Exits the function
EndFunc

Hi,

here's the countdown version:

#include <Date.au3>
_countDown(50000)

Func _countDown($Countdown)
    $seconds = _DateAdd('s', $Countdown / 1000, _NowCalc())
    Do
        Sleep(100)
        $sec = _DateDiff('s', _NowCalc(), $seconds)
        $string = StringFormat("%.02d" & ":" & "%.02d" & ":" & "%.02d", _
        Mod($sec / 3600, 24), Mod(($sec / 60), 60), Mod($sec, 60))
        ToolTip(@ScriptName & ": Time left before executing: " & $string , 0, 0)
    Until $sec = 0
EndFunc

;-))

Stefan

Share this post


Link to post
Share on other sites

Hi,

here's the countdown version....

;-))

Stefan

This one is match better to my script!

thanks again !!!! :D

Shay


"If the facts don't fit the theory, change the facts." Albert Einstein

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