AutoHotkey Community

It is currently May 25th, 2012, 7:21 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: June 2nd, 2007, 2:57 pm 
Offline

Joined: June 2nd, 2007, 1:33 pm
Posts: 9
Hello, I'm trying to do a simple OSD tool that tells me how many hours, minutes and seconds are left, If I insert a specified time.
I read some previous topic but I couldn't understand what I need

Until now is ok, because I can retrieve the amount of seconds left

What is the best way to proceed in order to have a result like HH:MM:SS?

I thought about format time, but I need a start format of YYYYMMDDHHMMSS and I don't have it, since I just have the amount of seconds

is there a fast command to convert number of seconds into a specific time format? thank you


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 2nd, 2007, 5:51 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8775
Refer AHK Documentation ( Example #3 in FormatTime )

:)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 2nd, 2007, 7:31 pm 
Offline

Joined: June 2nd, 2007, 1:33 pm
Posts: 9
I have a problem, i can't seem to include that in my script...

this is my current script

Code:
;On-screen display (OSD)
CustomColor = 99AA55  ; Can be any RGB color (it will be made transparent below).
Gui +LastFound +AlwaysOnTop +Caption +ToolWindow  ; +ToolWindow avoids a taskbar button and an alt-tab menu item.
Gui, Color, %CustomColor%
Gui, Font, s32  ; Set a large font size (32-point).
Gui, Add, Text, vMyText cBlue, XXX YYYYYYYY ; XX & YY serve to auto-size the window.
Gui, Add, Text, vMyTime cBlue, XXX YYYYYYYY ; XX & YY serve to auto-size the window.
WinSet, TransColor, %CustomColor% 150 ; Make all pixels of this color transparent and make the text itself translucent (150):

SetTimer, UpdateOSD, 200 ; Causes a subroutine to be launched automatically and repeatedly at a specified time interval.

Gosub, UpdateOSD  ; Make the first update immediate rather than waiting for the timer.
Gui, Show, x0 y80 NoActivate ; NoActivate avoids deactivating the currently active window.


UpdateOSD:
mysec := A_Now                 
arrivo := 20070602230000        ; this is the finishing time
EnvSub, mysec, %arrivo%, seconds


GuiControl,, MyText, %A_Hour%:%A_Min%:%A_Sec%
GuiControl,, MyTime, %mysec%

return



As you can see, I have a result of %mysec% that are the seconds left

and this is the code I can find on the help section, to convert seconds in hh:mm:ss with a function (from what i can understand)
Code:
; The following function converts the specified number of seconds into the corresponding
; number of hours, minutes, and seconds (hh:mm:ss format).

MsgBox % FormatSeconds(7384)  ; 7384 = 2 hours + 3 minutes + 4 seconds. It yields: 2:03:04

FormatSeconds(NumberOfSeconds)  ; Convert the specified number of seconds to hh:mm:ss format.
{
    time = 19990101  ; *Midnight* of an arbitrary date.
    time += %NumberOfSeconds%, seconds
    FormatTime, mmss, %time%, mm:ss
    return NumberOfSeconds//3600 ":" mmss  ; This method is used to support more than 24 hours worth of sections.
}




I can't seem to modify my current script adding this part, how can I see in the gui the result of a function, instead of a simple variable like %mysec% ??

help please


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 2nd, 2007, 9:34 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8775
Code:
;On-screen display (OSD)
CustomColor = 99AA55  ; Can be any RGB color (it will be made transparent below).
Gui +LastFound +AlwaysOnTop +Caption +ToolWindow  ; +ToolWindow avoids a taskbar button and an alt-tab menu item.
Gui, Color, %CustomColor%
Gui, Font, s32  ; Set a large font size (32-point).
Gui, Add, Text, vMyText cBlue, XXX YYYYYYYY ; XX & YY serve to auto-size the window.
Gui, Add, Text, vMyTime cBlue, XXX YYYYYYYY ; XX & YY serve to auto-size the window.
WinSet, TransColor, %CustomColor% 150 ; Make all pixels of this color transparent and make the text itself translucent (150):

SetTimer, UpdateOSD, 200 ; Causes a subroutine to be launched automatically and repeatedly at a specified time interval.

Gosub, UpdateOSD  ; Make the first update immediate rather than waiting for the timer.
Gui, Show, x0 y80 NoActivate ; NoActivate avoids deactivating the currently active window.


UpdateOSD:
mysec := A_Now                 
arrivo := 20070602230000        ; this is the finishing time
EnvSub, mysec, %arrivo%, seconds


GuiControl,, MyText, %A_Hour%:%A_Min%:%A_Sec%
GuiControl,, MyTime, % FormatSeconds( MySec )

Return ; // End of Auto-Execute Section

FormatSeconds(NumberOfSeconds)  ; Convert the specified number of seconds to hh:mm:ss format.
{
    time = 19990101  ; *Midnight* of an arbitrary date.
    time += %NumberOfSeconds%, seconds
    FormatTime, mmss, %time%, mm:ss
    return Round( NumberOfSeconds//3600 ) ":" mmss  ; This method is used to support more than 24 hours worth of sections.
}


:)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 3rd, 2007, 12:33 am 
Offline

Joined: June 2nd, 2007, 1:33 pm
Posts: 9
that's not working.. anyway ill try to see what is wrong


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 3rd, 2007, 9:53 am 
Offline

Joined: August 24th, 2005, 5:29 pm
Posts: 549
Location: Berlin / Germany
Code:
;On-screen display (OSD)
CustomColor = 99AA55  ; Can be any RGB color (it will be made transparent below).
Gui +LastFound +AlwaysOnTop +Caption +ToolWindow  ; +ToolWindow avoids a taskbar button and an alt-tab menu item.
Gui, Color, %CustomColor%
Gui, Font, s32  ; Set a large font size (32-point).
Gui, Add, Text, vMyText cBlue, -00:00:00 ; XX & YY serve to auto-size the window.
Gui, Add, Text, vMyTime cBlue, -00:00:00 ; XX & YY serve to auto-size the window.
WinSet, TransColor, %CustomColor% 150 ; Make all pixels of this color transparent and make the text itself translucent (150):

SetTimer, UpdateOSD, 200 ; Causes a subroutine to be launched automatically and repeatedly at a specified time interval.

Gosub, UpdateOSD  ; Make the first update immediate rather than waiting for the timer.
Gui, Show, x0 y80 NoActivate, Timer ; NoActivate avoids deactivating the currently active window.

Return  ; // End of Auto-Execute Section

GuiClose:
ExitApp

UpdateOSD:
arrivo := 20070603230000        ; this is the finishing time
mysec := arrivo                 
EnvSub, mysec, %A_Now%, seconds

GuiControl,, MyText, %A_Hour%:%A_Min%:%A_Sec%
GuiControl,, MyTime, % FormatSeconds( MySec )

Return

FormatSeconds(NumberOfSeconds)  ; Convert the specified number of seconds to hh:mm:ss format.
{
    time = 19990101  ; *Midnight* of an arbitrary date.
    time += %NumberOfSeconds%, seconds
    FormatTime, mmss, %time%, mm:ss
    hours := NumberOfSeconds // 3600 ; This method is used to support more than 24 hours worth of sections.
    hours := hours < 10 ? "0" . hours : hours
    return hours ":" mmss 
}

_________________
nick :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 3rd, 2007, 1:11 pm 
Offline

Joined: June 2nd, 2007, 1:33 pm
Posts: 9
thank you! that's great :)


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: azure, Bing [Bot], Google Feedfetcher and 65 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group