Jump to content

Convert Timer Into Hours Minutes & Seconds


 Share

Recommended Posts

This script works properply, but displays the time in milliseconds. But I want to display the time in hours:minutes:seconds

No chance with Function MODE. Senseless to reports about all my trials.

In a second step I want to multiply the minutes with a value for example "1,2".

Is it AutoIT3 without these options or my own incapability ? :whistle:

Thanks from Germany to the rest of the wonderful AutoIT3 world

Johannes

$begin = TimerStart()

$W_Title = "Timer"

while 1

Showstatus("Running for:" & TimerStop($begin))

sleep(1000)

wend

Func ShowStatus($msg)

if Not WinExists($W_Title,"") then

SplashTextOn($W_Title,$msg,300,100,1,1,6,"Arial",8,600)

else

ControlSetText($W_Title,"","Static1",$msg)

EndIf

EndFunc

Johannes LorenzBensheim, Germanyjlorenz1@web.de[post="12602"]Highlightning AutoIt Syntax in Notepad++ - Just copy in your Profile/application data/notepad++[/post]

Link to comment
Share on other sites

About dividing the timecode into h:m:s, how about this?

$begin = TimerStart()
$W_Title = "Timer"

while 1
  $dummy = TimerStop($begin)/1000

  $dummy2= mod ($dummy, 3600)
  $hours = ($dummy-$dummy2) / 3600
  $dummy = $dummy2
  
  $dummy2= mod ($dummy, 60)
  $minutes = ($dummy-$dummy2) / 60
  $dummy = $dummy2

  $seconds= round($dummy)
  Showstatus("Running for: " & $hours & "hours, " & $minutes & " minutes and " & $seconds & " seconds")

sleep(1000)
wend

Func ShowStatus($msg)
if Not WinExists($W_Title,"") then
  SplashTextOn($W_Title,$msg,300,100,1,1,6,"Arial",8,600)
else
  ControlSetText($W_Title,"","Static1",$msg)
EndIf
EndFunc

Greetings (from Germany, too)

Marc

Edited by Marc

Any of my own codes posted on the forum are free for use by others without any restriction of any kind. (WTFPL)

Link to comment
Share on other sites

Hi Marc,

thanks for your help :whistle: Naturally i tried your solution suggestion, but I get following error message:

$seconds= round($dummy) -unknown function ROUND

I found no entries about ROUND in help file. In a second trial I commented temporarily all entries about $seconds out and it works properly without seconds.

There's only the format of hours and minutes, which are disturbing me. 2 Minutes are showed as 2.000000. I prefers to show as only 2.

But this shouldn't diminish my thanks to you. It's only my first impression.

Greetings form Griesheim near Darmstadt/Germany

Johannes

Johannes LorenzBensheim, Germanyjlorenz1@web.de[post="12602"]Highlightning AutoIt Syntax in Notepad++ - Just copy in your Profile/application data/notepad++[/post]

Link to comment
Share on other sites

Hi Johannes,

the round() function has been introduced in 3.085, do you use an earlier version?

My output window looks fine, just says "2 seconds", nothing about "2.000".

I suppose after updating your AutoIt to the newest version (3.090),

you'll get the same results :whistle:

If not, don't hesitate to say a word...

Greetings from Leverkusen,

Marc

Any of my own codes posted on the forum are free for use by others without any restriction of any kind. (WTFPL)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...