It is currently September 29th, 2024, 1:32 pm

Countdown timer

General topics related to Rainmeter.
User avatar
1690Cat
Posts: 23
Joined: September 27th, 2012, 3:02 pm

Countdown timer

Post by 1690Cat »

Hi
i have been looking at all the countdown timers on deviant art,and all of them reset if i refresh my skins or switch off computer,is there anyway to keep the timer counting down,so when i switch comp back on it will still be counting down,and stop at the designated time,i only want hrs,mins,secs.if anyone can help with this it will be much appreciated...
User avatar
Brian
Developer
Posts: 2736
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: Countdown timer

Post by Brian »

Since you didn't provide any code, I will just give you a quick (and very crude) example of how to "save" the current value of a timer.

Note: This is not the most elegant solution, but it is a start.

Code: Select all

[Rainmeter]
DynamicWindowSize=1
OnCloseAction=!WriteKeyValue Variables CurrentValue [cCounter]

[Variables]
CurrentValue=10
MaxValue=10
Offset=#MaxValue#-#CurrentValue#

[cCounter]
Measure=Calc
Formula=((cCounter-1+(#MaxValue#+1)-(#Offset#))%(#MaxValue#+1))
IfEqualValue=#CurrentValue#
IfEqualAction=!SetVariable Offset 0
DynamicVariables=1

[Meter]
Meter=String
MeasureName=cCounter
FontColor=255,255,255
SolidColor=0,0,0
This is basically just a modified version of smurfier's independent count-down timer combined with an "OnCloseAction" to save the current counter. In order to start at the current value, we have to provide an "offset" for the initial value. However, we have to change the offset to 0 after we start counting, hence the IfActions.

Note: This only really works when you close the skin and open it back up. Refreshing the skin will only reset the counter to when you last opened the skin.

I hope that gives you a start.

-Brian
User avatar
1690Cat
Posts: 23
Joined: September 27th, 2012, 3:02 pm

Re: Countdown timer

Post by 1690Cat »

thanx brian for taken the effort to reply.i am new to rainmeter,but like it better than windows itself,i was only using someone else's countdown skin,as i still learning how to make my own from scratch.so if i put that bit of code u gave me into the other code it will work?.thanx again anyway brian.
User avatar
Brian
Developer
Posts: 2736
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: Countdown timer

Post by Brian »

1690Cat wrote:so if i put that bit of code u gave me into the other code it will work?
No it will not work for your skin, I was just giving an example of how to accomplish it (A crude one at that!).

It's going to impossible for anyone to help you since you have not posted any code. It would help if you could post the .ini file contents (inside

Code: Select all

 tags please).  ;-) 

-Brian
User avatar
bobgrosh
Posts: 134
Joined: May 1st, 2011, 10:33 pm

Re: Countdown timer

Post by bobgrosh »

Brian, That is very useful, I've wanted a timer to do that too.

I've bookmarked your code since I have a lot of timers for my TV/Radio station skins.

However....
If one wants to have the timer continue the countdown even while the computer goes into screensaver, sleep node, hibernation, or turned off, then an entirely different method would be needed.

Suppose that at 5 am you want to you want an alarm to go off at 4 PM.

The timer is set to 11 hours and started at 5am.

At 6am the computer goes into screensaver and then shuts down at 7am.
You come back from lunch 2pm and work until 5pm. You want the timer to remind you at 4PM, an hour before you go home.

To do this, one way would be to:
a) store the [StartTime],
b) calculate the [EndTime] by adding the user input duration to it.
c) display the remaining time by subtracting the [EndTime] from the current time.
d) alarm when the [EndTime] - current time is less than 1 second

Note (1)
This method means that if you returned from lunch after 4pm, then the alarm would happen when you boot your computer.

Note (2)
There would be no need to use the OnCloseAction and the timer would still work even if the computer crashed.



I never wrote such a timer because calculating the times correctly in rainmeter was a little beyond me when I tried to do it, I was used to being able to get the time in on windows as the internal date time number (on windows it is the number of seconds that have elapsed since midnight on January 1st, 1970)

It would be nice if Rainmeter could deal with date/time in the internal format.

Of course, this method would fail on 32 bit versions of windows In the year 2038 on January 19th if you set the alarm before 3:14 am UTC to alarm after that time due to the epoch on windows having started on midnight, January 1st 1970. However 64 bit windows systems are good for the next 290 billion years ! ;)
User avatar
1690Cat
Posts: 23
Joined: September 27th, 2012, 3:02 pm

Re: Countdown timer

Post by 1690Cat »

HI again Brian, i think i sent the file somewhere different just before,so trying again here,what it is i need the timer to be like a clock and carry on counting down when computer is switched off,so when i switch back on say 6 hours later it has counted them 6 hours and still counting down,if you know what i mean.sorry if i being a bother,but just can't find one anywhere that will do this.thanks.

Code: Select all

[Rainmeter]
Author=vlesun (vlesun@newmail.ru)
Reconfigured and Redsigned by Gerguter(gerguter@gmail.com)
AppVersion=100.11
Update=60

;--------------------------------------------------------------------
[Variables]
;Default value in sec * 10
DefaultInitialValue=3000 
DefaultAlarmBefore=0

;Path to sound files
AlarmBeforeSound=C:\Program Files\Rainmeter\Skins\Countdown\Jay & Silent Bob Strike Back - Doobie Snacks.wav
;EndTimeSound=C:\Program Files\Rainmeter\Skins\Countdown\Jay & Silent Bob Strike Back - Doobie Snacks.wav
EndTimeSound=C:\Program Files\Rainmeter\Skins\Countdown\Jay & Silent Bob Strike Back - Doobie Snacks.wav

ShowStopwatch=[!RainmeterShowMeter MeterStopwatchWindow][!RainmeterShowMeter MeterStopwatchDigit1][!RainmeterShowMeter MeterStopwatchDigit2][!RainmeterShowMeter MeterStopwatchDigit3][!RainmeterShowMeter MeterStopwatchDigit4][!RainmeterShowMeter MeterStopwatchStart1][!RainmeterShowMeter MeterStopwatchStop1][!RainmeterShowMeter MeterStopwatchReset1]
HideStopwatch=[!RainmeterHideMeter MeterStopwatchWindow][!RainmeterHideMeter MeterStopwatchDigit1][!RainmeterHideMeter MeterStopwatchDigit2][!RainmeterHideMeter MeterStopwatchDigit3][!RainmeterHideMeter MeterStopwatchDigit4][!RainmeterHideMeter MeterStopwatchStart1][!RainmeterHideMeter MeterStopwatchStop1][!RainmeterHideMeter MeterStopwatchReset1]
ShowTimer=[!RainmeterShowMeter MeterTimerWindow][!RainmeterShowMeter MeterTimerDigit1][!RainmeterShowMeter MeterTimerDigit2][!RainmeterShowMeter MeterTimerDigit3][!RainmeterShowMeter MeterTimerDigit4][!RainmeterShowMeter MeterTimerStart1][!RainmeterShowMeter MeterTimerStop1][!RainmeterShowMeter MeterTimerReset1][!RainmeterShowMeter MeterTimerSet1]
HideTimer=[!RainmeterHideMeter MeterTimerWindow][!RainmeterHideMeter MeterTimerDigit1][!RainmeterHideMeter MeterTimerDigit2][!RainmeterHideMeter MeterTimerDigit3][!RainmeterHideMeter MeterTimerDigit4][!RainmeterHideMeter MeterTimerStart1][!RainmeterHideMeter MeterTimerStop1][!RainmeterHideMeter MeterTimerReset1][!RainmeterHideMeter MeterTimerSet1]
ShowSetting=[!RainmeterShowMeter MeterSettingsTab][!RainmeterShowMeter MeterSettingUp11][!RainmeterShowMeter MeterSettingUp21][!RainmeterShowMeter MeterSettingUp31][!RainmeterShowMeter MeterSettingDown11][!RainmeterShowMeter MeterSettingDown21][!RainmeterShowMeter MeterSettingDown31][!RainmeterShowMeter MeterSettingClose1][!RainmeterShowMeter MeterSettingMore1][!RainmeterHideMeter MeterTimerStart1][!RainmeterHideMeter MeterTimerStop1][!RainmeterHideMeter MeterTimerReset1][!RainmeterHideMeter MeterTimerSet1][!RainmeterHideMeter MeterTimerTab]
HideSetting=[!RainmeterHideMeter MeterSettingsTab][!RainmeterHideMeter MeterSettingUp11][!RainmeterHideMeter MeterSettingUp21][!RainmeterHideMeter MeterSettingUp31][!RainmeterHideMeter MeterSettingDown11][!RainmeterHideMeter MeterSettingDown21][!RainmeterHideMeter MeterSettingDown31][!RainmeterHideMeter MeterSettingClose1][!RainmeterHideMeter MeterSettingMore1]
ShowAlarmBefore=[!RainmeterShowMeter MeterAlarmBeforeTab][!RainmeterShowMeter MeterAlarmBeforeUp11][!RainmeterShowMeter MeterAlarmBeforeUp21][!RainmeterShowMeter MeterAlarmBeforeUp31][!RainmeterShowMeter MeterAlarmBeforeDown11][!RainmeterShowMeter MeterAlarmBeforeDown21][!RainmeterShowMeter MeterAlarmBeforeDown31][!RainmeterShowMeter MeterAlarmBeforeClose1][!RainmeterHideMeter MeterTimerDigit1][!RainmeterHideMeter MeterTimerDigit2][!RainmeterHideMeter MeterTimerDigit3][!RainmeterHideMeter MeterTimerDigit4][!RainmeterShowMeter MeterAlarmBeforeDigit1][!RainmeterShowMeter MeterAlarmBeforeDigit2][!RainmeterShowMeter MeterAlarmBeforeDigit3][!RainmeterShowMeter MeterAlarmBeforeDigit4]
HideAlarmBefore=[!RainmeterHideMeter MeterAlarmBeforeTab][!RainmeterHideMeter MeterAlarmBeforeUp11][!RainmeterHideMeter MeterAlarmBeforeUp21][!RainmeterHideMeter MeterAlarmBeforeUp31][!RainmeterHideMeter MeterAlarmBeforeDown11][!RainmeterHideMeter MeterAlarmBeforeDown21][!RainmeterHideMeter MeterAlarmBeforeDown31][!RainmeterHideMeter MeterAlarmBeforeClose1][!RainmeterHideMeter MeterAlarmBeforeDigit1][!RainmeterHideMeter MeterAlarmBeforeDigit2][!RainmeterHideMeter MeterAlarmBeforeDigit3][!RainmeterHideMeter MeterAlarmBeforeDigit4]

;--------------------------------wa------------------------------------
;Interface
;--------------------------------------------------------------------


[MeterTimerTab]
Meter=String
X=68
Y=3
StringStyle=Normal
StringAlign=Left
FontFace=Eurostile LT ExtendedTwo
FontSize=10
FontColor=255,255,255,255
Text=Count Down
AntiAlias=1
LeftMouseDownAction=!Execute #ShowTimer##HideStopwatch#[!RainmeterRedraw]

[MeterSettingsTab]
Meter=String
X=2
Y=3
StringStyle=Normal
StringAlign=Left
FontFace=Eurostile LT ExtendedTwo
FontSize=10
FontColor=255,255,255,255
Text=Set Timer
AntiAlias=1
Hidden=1

[MeterSettingsTab]
Meter=Image
X=2
Y=3
ImageName=Settings.png
Hidden=1

[MeterAlarmBeforeTab]
Meter=Image
X=2
Y=3
ImageName=AlarmBefore.png
Hidden=1

;--------------------------------------------------------------------
;Counter for timer
;--------------------------------------------------------------------
[MeasureCounterTimerTime]
Measure=Time


[MeasureCounterTimer]
Measure=Calc
Formula=MeasureCounterTimer = 0 ? MeasureCounterTimerTime - MeasureTimer / 10 : MeasureCounterTimer
Disabled=1

[MeasureTimer]
Measure=Calc
Formula=MeasureCounterTimer = 0 ? MeasureTimer : (MeasureCounterTimerTime - MeasureCounterTimer) *10


;--------------------------------------------------------------------
;SetTimer
;--------------------------------------------------------------------
[MeasureSp]
Measure=Calc
Formula=(MeasureSp+1)%2
Disabled=1
IfAboveValue=0
IfAboveAction=!Execute [!RainmeterDisableMeasure MeasureSp]

[MeasureSm]
Measure=Calc
Formula=(MeasureSm+1)%2
Disabled=1
IfAboveValue=0
IfAboveAction=!Execute [!RainmeterDisableMeasure MeasureSm]

[MeasureMp]
Measure=Calc
Formula=(MeasureMp+1)%2
Disabled=1
IfAboveValue=0
IfAboveAction=!Execute [!RainmeterDisableMeasure MeasureMp]

[MeasureMm]
Measure=Calc
Formula=(MeasureMm+1)%2
Disabled=1
IfAboveValue=0
IfAboveAction=!Execute [!RainmeterDisableMeasure MeasureMm]

[MeasureHp]
Measure=Calc
Formula=(MeasureHp+1)%2
Disabled=1
IfAboveValue=0
IfAboveAction=!Execute [!RainmeterDisableMeasure MeasureHp]

[MeasureHm]
Measure=Calc
Formula=(MeasureHm+1)%2
Disabled=1
IfAboveValue=0
IfAboveAction=!Execute [!RainmeterDisableMeasure MeasureHm]



;--------------------------------------------------------------------
;Timer
;--------------------------------------------------------------------
[MeasureTimerSet]
Measure=Calc
Formula = (MeasureTimerSet + 10*MeasureSp - 10*MeasureSm + 600*MeasureMp - 600*MeasureMm + 36000*MeasureHp - 36000*MeasureHm + #DefaultInitialValue#)<0?(#DefaultInitialValue# * (-1)):(MeasureTimerSet + 10*MeasureSp - 10*MeasureSm + 600*MeasureMp - 600*MeasureMm + 36000*MeasureHp - 36000*MeasureHm)

[MeasureTimer2]
Measure=Calc
Format=%S
Formula=#DefaultInitialValue# - MeasureTimer + MeasureTimerSet
IfBelowValue=1
IfBelowAction=!Execute [!RainmeterDisableMeasure MeasureCounterTimer]

[MeasureTimer3]
Measure=Calc
Formula=MeasureCounterTimer=0?1:MeasureTimer2-1
IfBelow=0
IfBelowAction=!Execute [!RainmeterDisableMeasure MeasureCounterTimer][PLAY #EndTimeSound#]

[MeasureTimer4]
Measure=Calc
Format=%H
;Formula=MeasureAlarmBefore2<=0?-2:MeasureTimer2-MeasureAlarmBefore2-1
Formula=(MeasureCounterTimer * MeasureAlarmBefore2)=0?-2:MeasureTimer2-MeasureAlarmBefore2-1
IfEqualValue=-1
IfEqualAction=!Execute [PLAY #AlarmBeforeSound#]



[MeasureTimerDigit2]
Measure=Calc
Formula=(FLOOR(MeasureTimer2/10))%60
Format=%S

[MeasureTimerDigit3]
Measure=Calc
Formula=(FLOOR(MeasureTimer2/600))%60
Format=%M

[MeasureTimerDigit4]
Measure=Calc
Formula=(FLOOR(MeasureTimer2/36000))%100
Format=%H



[MeterTimerDigit2]
MeasureName=MeasureTimerDigit2
Meter=String
x=175
y=25
StringStyle=Normal
StringAlign=Left
Format=%S
FontFace=Eurostile LT ExtendedTwo
FontSize=20
FontColor=255,255,255,255
AntiAlias=1

[MeterTimerDigit3]
MeasureName=MeasureTimerDigit3
Meter=String
x=93
y=25
StringStyle=Normal
StringAlign=Left
Format=%M
FontFace=Eurostile LT ExtendedTwo
FontSize=20
FontColor=255,255,255,255
AntiAlias=1

[MeterTimerDigit4]
MeasureName=MeasureTimerDigit4
Meter=String
x=10
y=25
StringStyle=Normal
StringAlign=Left
Format=%H
FontFace=Eurostile LT ExtendedTwo
FontSize=20
FontColor=255,255,255,255
AntiAlias=1

[MeterTimerColon1]
Meter=String
x=70
y=25
StringStyle=Normal
StringAlign=Left
FontFace=Eurostile LT ExtendedTwo
FontSize=20
FontColor=255,255,255,255
Text=:
AntiAlias=1

[MeterTimerColon2]
Meter=String
x=155
y=25
StringStyle=Normal
StringAlign=Left
FontFace=Eurostile LT ExtendedTwo
FontSize=20
FontColor=255,255,255,255
Text=:
AntiAlias=1
--------------------------------------------------------------
;Buttons for Timer
;--------------------------------------------------------------------
[MeterTimerStart1]
Meter=String
X=2
Y=60
StringStyle=Normal
StringAlign=Left
FontFace=Eurostile LT ExtendedTwo
FontSize=12
FontColor=255,255,255,255
Text=Start
AntiAlias=1
LeftMouseDownAction=!Execute [!RainmeterEnableMeasure MeasureCounterTimer][!RainmeterShowMeter MeterTimerStart2][!RainmeterHideMeter MeterTimerStart1][!RainmeterRedraw]

[ButtonBack]
Meter=Image
X=2
Y=60
W=250
H=25
SolidColor=255,255,255,1
AntiAlias=1



[MeterTimerStart2]
Meter=String
X=3
Y=61
StringStyle=Normal
StringAlign=Left
FontFace=Eurostile LT ExtendedTwo
FontSize=12
FontColor=255,255,255,255
Text=Start
AntiAlias=1
Hidden=1
LeftMouseupAction=!execute [!RainmeterShowMeter MeterTimerStart1][!RainmeterHideMeter MeterTimerStart2][!RainmeterRedraw]
MouseLeaveAction=!execute [!RainmeterHideMeter MeterTimerStart2][!RainmeterShowMeter MeterTimerStart1][!RainmeterRedraw]

[MeterTimerStop1]
Meter=String
X=70	
Y=60
StringStyle=Normal
StringAlign=Left
FontFace=Eurostile LT ExtendedTwo
FontSize=12
FontColor=255,255,255,255
Text=Stop
AntiAlias=1
LeftMouseDownAction=!Execute [!RainmeterDisableMeasure MeasureCounterTimer][!RainmeterShowMeter MeterTimerStop2][!RainmeterHideMeter MeterTimerStop1][!RainmeterRedraw]

[MeterTimerStop2]
Meter=String
X=71
Y=61
StringStyle=Normal
StringAlign=Left
FontFace=Eurostile LT ExtendedTwo
FontSize=12
FontColor=255,255,255,255
Text=Stop
AntiAlias=1
Hidden=1
LeftMouseupAction=!execute [!RainmeterShowMeter MeterTimerStop1][!RainmeterHideMeter MeterTimerStop2][!RainmeterRedraw]
MouseLeaveAction=!execute [!RainmeterHideMeter MeterTimerStop2][!RainmeterShowMeter MeterTimerStop1][!RainmeterRedraw]


[MeterTimerReset1]
Meter=String
X=130
Y=60
StringStyle=Normal
StringAlign=Left
FontFace=Eurostile LT ExtendedTwo
FontSize=12
FontColor=255,255,255,255
Text=Reset
AntiAlias=1
LeftMouseDownAction=!Execute [!RainmeterDisableMeasure MeasureTimer][!RainmeterShowMeter MeterTimerReset2][!RainmeterHideMeter MeterTimerReset1][!RainmeterRedraw]

[MeterTimerReset2]
Meter=String
X=131
Y=61
StringStyle=Normal
StringAlign=Left
FontFace=Eurostile LT ExtendedTwo
FontSize=12
FontColor=255,255,255,255
Text=Reset
AntiAlias=1
Hidden=1
LeftMouseupAction=!execute [!RainmeterEnableMeasure MeasureTimer][!RainmeterShowMeter MeterTimerReset1][!RainmeterHideMeter MeterTimerReset2][!RainmeterRedraw]
MouseLeaveAction=!execute [!RainmeterEnableMeasure MeasureTimer][!RainmeterHideMeter MeterTimerReset2][!RainmeterShowMeter MeterTimerReset1][!RainmeterRedraw]

[MeterTimerSet1]
Meter=String
X=200
Y=60
StringStyle=Normal
StringAlign=Left
FontFace=Eurostile LT ExtendedTwo
FontSize=12
FontColor=255,255,255,255
Text=Set
AntiAlias=1
LeftMouseDownAction=!Execute [!RainmeterShowMeter MeterTimerSet2][!RainmeterHideMeter MeterTimerSet1][!RainmeterRedraw]

[MeterTimerSet2]
Meter=String
X=201
Y=61
StringStyle=Normal
StringAlign=Left
FontFace=Eurostile LT ExtendedTwo
FontSize=12
FontColor=255,255,255,255
Text=Set
AntiAlias=1
Hidden=1
LeftMouseupAction=!execute [!RainmeterShowMeter MeterSettingsTab][!RainmeterShowMeter MeterTimerSet1][!RainmeterHideMeter MeterTimerSet2]#ShowSetting#[!RainmeterRedraw]
MouseLeaveAction=!execute [!RainmeterHideMeter MeterTimerSet2][!RainmeterShowMeter MeterTimerSet1][!RainmeterRedraw]

;--------------------------------------------------------------------
;Buttons for Settings
;--------------------------------------------------------------------
[Line]
Meter=String
X=30
Y=60
StringStyle=Normal
StringAlign=Left
FontFace=Eurostile LT ExtendedTwo
FontSize=12
FontColor=255,255,255,255
Text=|
AntiAlias=1
Hidden=1

[Line2]
Meter=String
X=30
Y=60
StringStyle=Normal
StringAlign=Left
FontFace=Eurostile LT ExtendedTwo
FontSize=12
FontColor=255,255,255,255
Text=|
AntiAlias=1
Hidden=1

[MeterSettingUp11]
Meter=String
X=12
Y=60
StringStyle=Normal
StringAlign=Left
FontFace=Eurostile LT ExtendedTwo
FontSize=12
FontColor=255,255,255,255
Text=+
AntiAlias=1
LeftMouseDownAction=!Execute [!RainmeterEnableMeasure MeasureHp][!RainmeterShowMeter MeterSettingUp12][!RainmeterHideMeter MeterSettingUp11][!RainmeterRedraw]
Hidden=1

[MeterSettingUp12]
Meter=String
X=13
Y=61
StringStyle=Normal
StringAlign=Left
FontFace=Eurostile LT ExtendedTwo
FontSize=12
FontColor=255,255,255,255
Text=+
AntiAlias=1
LeftMouseupAction=!execute [!RainmeterShowMeter MeterSettingUp11][!RainmeterHideMeter MeterSettingUp12][!RainmeterRedraw]
MouseLeaveAction=!execute [!RainmeterHideMeter MeterSettingUp12][!RainmeterShowMeter MeterSettingUp11][!RainmeterRedraw]
Hidden=1

[MeterSettingDown11]
Meter=String
X=30
Y=60
StringStyle=Normal
StringAlign=Left
FontFace=Eurostile LT ExtendedTwo
FontSize=12
FontColor=255,255,255,255
Text=-
AntiAlias=1
LeftMouseDownAction=!Execute [!RainmeterEnableMeasure MeasureHm][!RainmeterShowMeter MeterSettingDown12][!RainmeterHideMeter MeterSettingDown11][!RainmeterRedraw]
Hidden=1

[MeterSettingDown12]
Meter=String
X=31
Y=61
StringStyle=Normal
StringAlign=Left
FontFace=Eurostile LT ExtendedTwo
FontSize=12
FontColor=255,255,255,255
Text=-
AntiAlias=1
LeftMouseupAction=!execute [!RainmeterShowMeter MeterSettingDown11][!RainmeterHideMeter MeterSettingDown12][!RainmeterRedraw]
MouseLeaveAction=!execute [!RainmeterHideMeter MeterSettingDown12][!RainmeterShowMeter MeterSettingDown11][!RainmeterRedraw]
Hidden=1

[MeterSettingUp21]
Meter=String
X=70
Y=60
StringStyle=Normal
StringAlign=Left
FontFace=Eurostile LT ExtendedTwo
FontSize=12
FontColor=255,255,255,255
Text=+
AntiAlias=1
LeftMouseDownAction=!Execute [!RainmeterEnableMeasure MeasureMp][!RainmeterShowMeter MeterSettingUp22][!RainmeterHideMeter MeterSettingUp21][!RainmeterRedraw]
Hidden=1

[MeterSettingUp22]
Meter=String
X=71
Y=61
StringStyle=Normal
StringAlign=Left
FontFace=Eurostile LT ExtendedTwo
FontSize=12
FontColor=255,255,255,255
Text=+
AntiAlias=1
LeftMouseupAction=!execute [!RainmeterShowMeter MeterSettingUp21][!RainmeterHideMeter MeterSettingUp22][!RainmeterRedraw]
MouseLeaveAction=!execute [!RainmeterHideMeter MeterSettingUp22][!RainmeterShowMeter MeterSettingUp21][!RainmeterRedraw]
Hidden=1

[MeterSettingDown21]
Meter=String
X=90
Y=60
StringStyle=Normal
StringAlign=Left
FontFace=Eurostile LT ExtendedTwo
FontSize=12
FontColor=255,255,255,255
Text=-
AntiAlias=1
LeftMouseDownAction=!Execute [!RainmeterEnableMeasure MeasureMm][!RainmeterShowMeter MeterSettingDown22][!RainmeterHideMeter MeterSettingDown21][!RainmeterRedraw]
Hidden=1

[MeterSettingDown22]
Meter=String
X=91
Y=61
StringStyle=Normal
StringAlign=Left
FontFace=Eurostile LT ExtendedTwo
FontSize=12
FontColor=255,255,255,255
Text=-
AntiAlias=1
LeftMouseupAction=!execute [!RainmeterShowMeter MeterSettingDown21][!RainmeterHideMeter MeterSettingDown22][!RainmeterRedraw]
MouseLeaveAction=!execute [!RainmeterHideMeter MeterSettingDown22][!RainmeterShowMeter MeterSettingDown21][!RainmeterRedraw]
Hidden=1

[MeterSettingUp31]
Meter=String
X=130
Y=60
StringStyle=Normal
StringAlign=Left
FontFace=Eurostile LT ExtendedTwo
FontSize=12
FontColor=255,255,255,255
Text=+
AntiAlias=1
LeftMouseDownAction=!Execute [!RainmeterEnableMeasure MeasureSp][!RainmeterShowMeter MeterSettingUp32][!RainmeterHideMeter MeterSettingUp31][!RainmeterRedraw]
Hidden=1

[MeterSettingUp32]
Meter=String
X=131
Y=61
StringStyle=Normal
StringAlign=Left
FontFace=Eurostile LT ExtendedTwo
FontSize=12
FontColor=255,255,255,255
Text=+
AntiAlias=1
LeftMouseupAction=!execute [!RainmeterShowMeter MeterSettingUp31][!RainmeterHideMeter MeterSettingUp32][!RainmeterRedraw]
MouseLeaveAction=!execute [!RainmeterHideMeter MeterSettingUp32][!RainmeterShowMeter MeterSettingUp31][!RainmeterRedraw]
Hidden=1

[MeterSettingDown31]
Meter=String
X=150
Y=60
StringStyle=Normal
StringAlign=Left
FontFace=Eurostile LT ExtendedTwo
FontSize=12
FontColor=255,255,255,255
Text=-
AntiAlias=1
LeftMouseDownAction=!Execute [!RainmeterEnableMeasure MeasureSm][!RainmeterShowMeter MeterSettingDown32][!RainmeterHideMeter MeterSettingDown31][!RainmeterRedraw]
Hidden=1

[MeterSettingDown32]
Meter=String
X=151
Y=61
StringStyle=Normal
StringAlign=Left
FontFace=Eurostile LT ExtendedTwo
FontSize=12
FontColor=255,255,255,255
Text=-
AntiAlias=1
LeftMouseupAction=!execute [!RainmeterShowMeter MeterSettingDown31][!RainmeterHideMeter MeterSettingDown32][!RainmeterRedraw]
MouseLeaveAction=!execute [!RainmeterHideMeter MeterSettingDown32][!RainmeterShowMeter MeterSettingDown31][!RainmeterRedraw]
Hidden=1


[MeterSettingClose1]
Meter=String
X=195
Y=60
StringStyle=Normal
StringAlign=Left
FontFace=Eurostile LT ExtendedTwo
FontSize=12
FontColor=255,255,255,255
Text=OK
AntiAlias=1
LeftMouseDownAction=!Execute [!RainmeterShowMeter MeterSettingClose2][!RainmeterHideMeter MeterSettingClose1][!RainmeterRedraw]
Hidden=1

[MeterSettingClose2]
Meter=String
X=196
Y=61
StringStyle=Normal
StringAlign=Left
FontFace=Eurostile LT ExtendedTwo
FontSize=12
FontColor=255,255,255,255
Text=OK
AntiAlias=1
LeftMouseupAction=!execute [!RainmeterHideMeter MeterSettingClose2][!RainmeterShowMeter MeterSettingClose1][!RainmeterShowMeter MeterTimerTab]#ShowTimer##HideSetting#[!RainmeterRedraw]
MouseLeaveAction=!execute [!RainmeterHideMeter MeterSettingClose2][!RainmeterShowMeter MeterSettingClose1][!RainmeterRedraw]
Hidden=1

User avatar
Brian
Developer
Posts: 2736
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: Countdown timer

Post by Brian »

bobgrosh wrote:It would be nice if Rainmeter could deal with date/time in the internal format.
Have you seen the new TimeStamp option for Time measures?
bobgrosh wrote: ... the epoch on windows having started on midnight, January 1st 1970
I think you are thinking of Unix Time. For Windows, time started Jan 1, 1601 and lasts for about 30,000 years.
1690Cat wrote:HI again Brian, i think i sent the file somewhere different just before,so trying again here,what it is i need the timer to be like a clock and carry on counting down when computer is switched off,so when i switch back on say 6 hours later it has counted them 6 hours and still counting down,if you know what i mean.sorry if i being a bother,but just can't find one anywhere that will do this.thanks.
Ok, I tried messing around with that old, dated (and inefficient skin) before I just gave up and wrote a new countdown timer myself.

So here it is (beware, it uses Lua):
Countdown.ini

Code: Select all

[Rainmeter]
DynamicWindowSize=1
BackGroundMode=2
SolidColor=0,0,0,180

[Variables]
Month=12
Day=21
Year=2012
Hour=00
Minute=00
Second=00

[TextStyle1]
FontFace=Tahoma
FontColor=255,255,255,255
FontSize=10
StringEffect=Shadow
StringEffectColor=0,0,0,180
X=2R
Y=r
DynamicVariables=1

[TextStyle2]
FontSize=20

[CountDown]
Measure=Script
ScriptFile=CountDown.lua
Action=!SetOption Days SolidColor "255,0,0,180"

[Input]
Measure=Plugin
Plugin=InputText
SolidColor=0,0,150
FontColor=255,255,255
FontFace=Tahoma
FontSize=10
FocusDismiss=1
Y=0
W=20
H=18
Command1=[!WriteKeyValue Variables Month "$UserInput$" "#CURRENTPATH##CURRENTFILE#" X="95" DefaultValue="#Month#"][!Refresh #CURRENTCONFIG#]
Command2=[!WriteKeyValue Variables Day "$UserInput$" "#CURRENTPATH##CURRENTFILE#" X="125" DefaultValue="#Day#"][!Refresh #CURRENTCONFIG#]
Command3=[!WriteKeyValue Variables Year "$UserInput$" "#CURRENTPATH##CURRENTFILE#" X="155" W="35" DefaultValue="#Year#"][!Refresh #CURRENTCONFIG#]
Command4=[!WriteKeyValue Variables Hour "$UserInput$" "#CURRENTPATH##CURRENTFILE#" X="200" DefaultValue="#Hour#"][!Refresh #CURRENTCONFIG#]
Command5=[!WriteKeyValue Variables Minute "$UserInput$" "#CURRENTPATH##CURRENTFILE#" X="230" DefaultValue="#Minute#"][!Refresh #CURRENTCONFIG#]
Command6=[!WriteKeyValue Variables Second "$UserInput$" "#CURRENTPATH##CURRENTFILE#" X="260" DefaultValue="#Second#"][!Refresh #CURRENTCONFIG#]

[TargetTitle]
Meter=String
MeterStyle=TextStyle1
Text=Countdown to:

[TargetMonth]
Meter=String
MeterStyle=TextStyle1
Text=#Month# /
LeftMouseUpAction=!CommandMeasure Input "ExecuteBatch 1"

[TargetDay]
Meter=String
MeterStyle=TextStyle1
Text=#Day# /
LeftMouseUpAction=!CommandMeasure Input "ExecuteBatch 2"

[TargetYear]
Meter=String
MeterStyle=TextStyle1
Text=#Year# |
LeftMouseUpAction=!CommandMeasure Input "ExecuteBatch 3"

[TargetHour]
Meter=String
MeterStyle=TextStyle1
Text=#Hour# :
LeftMouseUpAction=!CommandMeasure Input "ExecuteBatch 4"

[TargetMinute]
Meter=String
MeterStyle=TextStyle1
Text=#Minute# :
LeftMouseUpAction=!CommandMeasure Input "ExecuteBatch 5"

[TargetSecond]
Meter=String
MeterStyle=TextStyle1
Text=#Second#
LeftMouseUpAction=!CommandMeasure Input "ExecuteBatch 6"

[Days]
Meter=String
MeterStyle=TextStyle1 | TextStyle2
X=0
Y=2R

[Hours]
Meter=String
MeterStyle=TextStyle1 | TextStyle2

[Minutes]
Meter=String
MeterStyle=TextStyle1 | TextStyle2

[Seconds]
Meter=String
MeterStyle=TextStyle1 | TextStyle2
Countdown.lua

Code: Select all

function Initialize()
	--Grab the target date/time variables
	tMonth  = SKIN:GetVariable('Month')
	tDay    = SKIN:GetVariable('Day')
	tYear   = SKIN:GetVariable('Year')
	tHour   = SKIN:GetVariable('Hour')
	tMinute = SKIN:GetVariable('Minute')
	tSecond = SKIN:GetVariable('Second')
end -- function Initialize


function Update()
	local timeTbl = {month=tMonth, day=tDay, year=tYear, hour=tHour, min=tMinute, sec=tSecond}
	local nTime = os.time(timeTbl) - os.time()
	
	if nTime < 0 then
		SKIN:Bang('!SetOption', 'Days', 'Text', 'Times Up!')
		SKIN:Bang(SELF:GetOption('Action'))
		return
	end
	
	local days = math.floor(nTime / 60 / 60 / 24)
	local hours = (math.floor(nTime / 60 / 60) % 24)
	local minutes = (math.floor(nTime / 60 ) % 60)
	local seconds = (math.floor(nTime) % 60)
	
	SKIN:Bang('!SetOption', 'Days', 'Text', days..'d')
	SKIN:Bang('!SetOption', 'Hours', 'Text', hours..'h')
	SKIN:Bang('!SetOption', 'Minutes', 'Text', minutes..'m')
	SKIN:Bang('!SetOption', 'Seconds', 'Text', seconds..'s')
	
end -- function Update
Once the skin is loaded, all you have to do is click on each number (on the first line)...and a text box should appear where you enter the appropriate date/time number. Obviously if you change the FontFace, FontSize, etc., you may have to change some of the X, Y, W, and H values.

When the timer runs out, the script will run the action defined in the [Countdown] section under "Action".

-Brian
User avatar
1690Cat
Posts: 23
Joined: September 27th, 2012, 3:02 pm

Re: Countdown timer

Post by 1690Cat »

Hi Brian,i want to thank you for your time and effort in doing that timer for me.it works great just what i needed.i downloaded one similar a couple weeks back,but when time ran out it just carried on with a minus added to it,but was no good for my needs.this one stops and tells me, and that is what i needed.thanks again.
Gordon-1979
Posts: 18
Joined: November 3rd, 2011, 9:01 pm

Re: Countdown timer

Post by Gordon-1979 »

I have this Skin (Countdown.ini, with CountDown.lua), but would like to use my own numbers.
The Numbers are in .png
How can I change it?


Countdown.ini

Code: Select all

[Rainmeter]
DynamicWindowSize=1
BackGroundMode=2
SolidColor=0,0,0,180

[Variables]
Month=12
Day=21
Year=2012
Hour=00
Minute=00
Second=00

[TextStyle1]
FontFace=Tahoma
FontColor=255,255,255,255
FontSize=10
StringEffect=Shadow
StringEffectColor=0,0,0,180
X=2R
Y=r
DynamicVariables=1

[TextStyle2]
FontSize=20

[CountDown]
Measure=Script
ScriptFile=CountDown.lua
Action=!SetOption Days SolidColor "255,0,0,180"

[Input]
Measure=Plugin
Plugin=InputText
SolidColor=0,0,150
FontColor=255,255,255
FontFace=Tahoma
FontSize=10
FocusDismiss=1
Y=0
W=20
H=18
Command1=[!WriteKeyValue Variables Month "$UserInput$" "#CURRENTPATH##CURRENTFILE#" X="95" DefaultValue="#Month#"][!Refresh #CURRENTCONFIG#]
Command2=[!WriteKeyValue Variables Day "$UserInput$" "#CURRENTPATH##CURRENTFILE#" X="125" DefaultValue="#Day#"][!Refresh #CURRENTCONFIG#]
Command3=[!WriteKeyValue Variables Year "$UserInput$" "#CURRENTPATH##CURRENTFILE#" X="155" W="35" DefaultValue="#Year#"][!Refresh #CURRENTCONFIG#]
Command4=[!WriteKeyValue Variables Hour "$UserInput$" "#CURRENTPATH##CURRENTFILE#" X="200" DefaultValue="#Hour#"][!Refresh #CURRENTCONFIG#]
Command5=[!WriteKeyValue Variables Minute "$UserInput$" "#CURRENTPATH##CURRENTFILE#" X="230" DefaultValue="#Minute#"][!Refresh #CURRENTCONFIG#]
Command6=[!WriteKeyValue Variables Second "$UserInput$" "#CURRENTPATH##CURRENTFILE#" X="260" DefaultValue="#Second#"][!Refresh #CURRENTCONFIG#]

[TargetTitle]
Meter=String
MeterStyle=TextStyle1
Text=Countdown to:

[TargetMonth]
Meter=String
MeterStyle=TextStyle1
Text=#Month# /
LeftMouseUpAction=!CommandMeasure Input "ExecuteBatch 1"

[TargetDay]
Meter=String
MeterStyle=TextStyle1
Text=#Day# /
LeftMouseUpAction=!CommandMeasure Input "ExecuteBatch 2"

[TargetYear]
Meter=String
MeterStyle=TextStyle1
Text=#Year# |
LeftMouseUpAction=!CommandMeasure Input "ExecuteBatch 3"

[TargetHour]
Meter=String
MeterStyle=TextStyle1
Text=#Hour# :
LeftMouseUpAction=!CommandMeasure Input "ExecuteBatch 4"

[TargetMinute]
Meter=String
MeterStyle=TextStyle1
Text=#Minute# :
LeftMouseUpAction=!CommandMeasure Input "ExecuteBatch 5"

[TargetSecond]
Meter=String
MeterStyle=TextStyle1
Text=#Second#
LeftMouseUpAction=!CommandMeasure Input "ExecuteBatch 6"

[Days]
Meter=String
MeterStyle=TextStyle1 | TextStyle2
X=0
Y=2R

[Hours]
Meter=String
MeterStyle=TextStyle1 | TextStyle2

[Minutes]
Meter=String
MeterStyle=TextStyle1 | TextStyle2

[Seconds]
Meter=String
MeterStyle=TextStyle1 | TextStyle2
Countdown.lua

Code: Select all

function Initialize()
	--Grab the target date/time variables
	tMonth  = SKIN:GetVariable('Month')
	tDay    = SKIN:GetVariable('Day')
	tYear   = SKIN:GetVariable('Year')
	tHour   = SKIN:GetVariable('Hour')
	tMinute = SKIN:GetVariable('Minute')
	tSecond = SKIN:GetVariable('Second')
end -- function Initialize


function Update()
	local timeTbl = {month=tMonth, day=tDay, year=tYear, hour=tHour, min=tMinute, sec=tSecond}
	local nTime = os.time(timeTbl) - os.time()
	
	if nTime < 0 then
		SKIN:Bang('!SetOption', 'Days', 'Text', 'Times Up!')
		SKIN:Bang(SELF:GetOption('Action'))
		return
	end
	
	local days = math.floor(nTime / 60 / 60 / 24)
	local hours = (math.floor(nTime / 60 / 60) % 24)
	local minutes = (math.floor(nTime / 60 ) % 60)
	local seconds = (math.floor(nTime) % 60)
	
	SKIN:Bang('!SetOption', 'Days', 'Text', days..'d')
	SKIN:Bang('!SetOption', 'Hours', 'Text', hours..'h')
	SKIN:Bang('!SetOption', 'Minutes', 'Text', minutes..'m')
	SKIN:Bang('!SetOption', 'Seconds', 'Text', seconds..'s')
	
end -- function Update