Sign in to follow this  
Followers 0
Qwerty212

Stuck with Seconds to HH:MM:SS format during a countdown

4 posts in this topic

Hello from Barcelona, i'm trying to format a number based on seconds to a format like HH:MM:SS.

I've been searching on Help Files and googling but the topics related didn't help me :mellow:

In my script I've got a Input box asking for a time in minutes that the user wants something to happen.

$input = GUICtrlCreateInput("", 341, 228, 35, 20)

Then I convert the value of that input to minutes doing a Input*60:

; Application Starting Countdown, Y value is the time you will waiting in seconds.
$X = 0
$Y = GUICtrlRead($input)*60
$message = ""
$message1 = "time until arrive " & $messageh
SplashTextOn("Please wait!", $messageh, 600, 530, -1, -1, 1, "", 110)

Next I show the countdown (in seconds) on a splash screen

While $Y > $X
    $message = $Y & @LF
    ControlSetText("Please wait!", "", "Static1", $message1 & $message)
    sleep(1000)
    $Y = $Y - 1
WEnd

Looking on the forum I've found some scripts to format a number from seconds (in my case the value $message) to HH:MM:SS

$sec2time_hour = Int($vid_duration / 3600)
$sec2time_min = Int(($vid_duration - $sec2time_hour * 3600) / 60)
$sec2time_sec = $vid_duration - $sec2time_hour * 3600 - $sec2time_min * 60
$vid_duration = StringFormat('%02d:%02d:%02d', $sec2time_hour, $sec2time_min, $sec2time_sec)

I'm completely lost. I've tried to change $vid_duration for $message to see if it returns the desired format on the splash screen (HH:MM:SS and the value decreasing until zero) but nothing worked :P

Could you please help me with that?

Share this post


Link to post
Share on other sites



Try this:

While $Y > $X
    $message = StringFormat("%02d:%02d:%02d\n", Floor($y / 3600), Mod(Floor($y / 60), 60), Mod($y, 60))
    ControlSetText("Please wait!", "", "Static1", $message1 & $message)
    sleep(1000)
    $Y = $Y - 1
WEnd

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

Try this:

While $Y > $X
    $message = StringFormat("%02d:%02d:%02d\n", Floor($y / 3600), Mod(Floor($y / 60), 60), Mod($y, 60))
    ControlSetText("Please wait!", "", "Static1", $message1 & $message)
    sleep(1000)
    $Y = $Y - 1
WEnd

It simply WORKED!! You are the man!

Thank you very much!!!

What does the \n value means after the format string?

Share this post


Link to post
Share on other sites

\n = newline = linefeed = 0x0A = @LF

You're welcome!


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

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