Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Countdown showing days hours min seconds
#1
Is there an easy way of doing a countdown to a future date/time so that it shows up in this format?

4 days 18 hours 36 minutes 18 seconds
or for bonus points

4:18:36:18
An old blog on QM coding and automation.

The Macro Hook
#2
Macro Macro1276
Code:
Copy      Help
DATE dFuture="01/01/2010"

rep
,DATE dNow.getclock
,if(dNow>=dFuture) break
,
,SYSTEMTIME t
,int days=dFuture.diff(dNow t)
,
,str s.format("%i days %i hours %i minutes %i seconds" days t.wHour t.wMinute t.wSecond)
,OnScreenDisplay s 2 0 0 0 0 0 5|8 "cd452"
,1

OsdHide "cd452"
#3
this works fantastic!
I made some changes for posterity...
This one is actually giving me the countdown for my last day at work and the other for when I move to Minnesota.

Thanks Gintaras!
Function CountDown_Timer
Code:
Copy      Help
DATE dFuture="11/11/09 16:00:00"
DATE dFutureMove="11/15/09 8:00:00"
if(IsThreadRunning("MMessage_Board"))
,shutdown -6 0 "MMessage_Board"
mac "MMessage_Board"
0.4
rep
,DATE dNow.getclock
,if(dNow>=dFuture) break
,SYSTEMTIME t tm
,int days=dFuture.diff(dNow t)
,int daysmove=dFutureMove.diff(dNow tm)
,str s.format(" %i Days %i Hours %i Min %i Sec" days t.wHour t.wMinute t.wSecond)
,str sm.format(" %i Days %i Hours %i Min %i Sec" daysmove tm.wHour tm.wMinute tm.wSecond)
,s.setwintext(id(7 win("MMessage_Board" "#32770")))
,sm.setwintext(id(3 win("MMessage_Board" "#32770")))
,;OnScreenDisplay s 0 494 -1024 0 32 0 4|8 "cd452"
,1

OsdHide "cd452"


Here's the dialog for it.

Function MMessage_Board
Code:
Copy      Help
;\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages
;GdiObject- brush=CreateSolidBrush(TRANSPARENT) ;;add this
GdiObject- brush=CreateSolidBrush(ColorFromRGB(147 232 237)) ;;add this
if(!ShowDialog("MMessage_Board" &MMessage_Board 0 0 64 0 0 0 494 0 )) ret


;BEGIN DIALOG
;0 "" 0x90000A44 0x100 0 0 255 44 "MMessage_Board"
;7 Static 0x54000000 0x0 0 0 255 22 ""
;3 Static 0x54000000 0x0 0 22 255 44 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2030109 "" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,,int+ allow=1
,,CFont-- f.Create("Arial" 18)
,,f.SetFont(id(7 hDlg))
,,f.SetFont(id(3 hDlg))
,,ret brush
,case WM_CTLCOLORSTATIC
,,SetBkMode wParam brush
,,ret brush
,case WM_DESTROY
,,shutdown -6 0 "CountDown_Timer"
,case WM_COMMAND goto messages2


ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
An old blog on QM coding and automation.

The Macro Hook


Forum Jump:


Users browsing this thread: 1 Guest(s)