It is currently October 12th, 2024, 3:37 am

Simple countdown timer

Get help with creating, editing & fixing problems with skins
User avatar
sl23
Posts: 1831
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Simple countdown timer

Post by sl23 »

:welcome:
Last edited by sl23 on September 4th, 2024, 7:04 am, edited 1 time in total.
57686174 77696C6C 6265 77696C6C 6265
User avatar
balala
Rainmeter Sage
Posts: 16651
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Simple countdown timer

Post by balala »

sl23 wrote: July 27th, 2021, 8:49 pm Ah ok, I removed the menu temporarily as I won't need it, least not in it's current form. :)
Alright, feel free to come back with your questions, if any arises.
User avatar
sl23
Posts: 1831
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Simple countdown timer

Post by sl23 »

:welcome:
Last edited by sl23 on September 4th, 2024, 7:04 am, edited 1 time in total.
57686174 77696C6C 6265 77696C6C 6265
User avatar
balala
Rainmeter Sage
Posts: 16651
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Simple countdown timer

Post by balala »

sl23 wrote: July 27th, 2021, 10:15 pm I would definitely like some help with the Roundline meter though! I can't seem to get it to work! I've tried to use the MeasureName=mCounterTimer but it just stays green when the timer starts.
Ok, done. Have added a MaxVal variable, which keeps track of the max value of the measure used into the MeasureName option of the [RoundBarFore] roundline meter. I changed this measure from the initial MeasureName=mCounterTimer to MeasureName=mTimer2. The code I posting below definitely is not the final code, it can and has to be improved, but see if the Roundline meter(s) is/are working as expected, because there might be some other approaches as well (for instance to increas the green roundline, instead of decreasing it, as it is now).

Code: Select all

[Rainmeter]
Author=zzeneg & balala
AppVersion=10
Update=50
BackgroundMode=2
SolidColor=0,0,0,1
DynamicWindowSize=1
;MouseOverAction=[!ShowMeter Menu][!ShowMeter More][!ShowMeter Close]
;MouseLeaveAction=[!HideMeter Menu][!HideMeter More][!HideMeter Close]
OnRefreshAction=[!ShowMeter Action1][!HideMeter Action2][!HideMeter Action3][!HideMeter Action4][!HideMeter Action5][!HideMeter Action6][!DisableMeasure mTimer4][!HideMeter Stop]

[Bg]
Meter=Shape
Shape=Rectangle Rectangle 1,1,150,60,5 | Extend StrokeSize | Stroke Color 128,255,0,100 | Fill Color 0,0,0,120
StrokeSize=StrokeWidth 0
MouseOverAction=[!SetOption #CURRENTSECTION# StrokeSize "StrokeWidth 2"][!UpdateMeter *][!Redraw]
MouseLeaveAction=[!SetOption #CURRENTSECTION# StrokeSize "StrokeWidth 0"][!UpdateMeter *][!Redraw]
StrokeAlpha=Stroke Color 128,255,0,100
DynamicVariables=1

[Variables]
Sound=alarm.wav

Act=Hibernate
DefaultInitialValue=6000
MaxVal=#DefaultInitialValue#
;DefaultInitialValue is the time (in one-tenth of seconds!) which appears when you refresh the skin. 

ShowTimer=[!ShowMeterGroup Controls]
HideTimer=[!HideMeterGroup Controls]
ShowSetting=[!ShowMeterGroup SetTimer]
HideSetting=[!HideMeterGroup SetTimer]

;========================================
; STYLES
;========================================
[sAllText]
FontFace=Aller
StringStyle=Bold
StringAlign=Center
FontSize=9
FontColor=255,255,255,200
AntiAlias=1

StringEffect=SHADOW
FontEffectColor=0,0,0,40

[sHighlight]
MouseOverAction=[!SetOption #CURRENTSECTION# FontColor "128,255,0"] [!UpdateMeter #CURRENTSECTION#] [!Redraw]
MouseLeaveAction=[!SetOption #CURRENTSECTION# FontColor ""] [!UpdateMeter #CURRENTSECTION#] [!Redraw]

;========================================
; MEASURES
;========================================
[mTime]
Measure=Time

[mCounterTimer]
Measure=Calc
Formula=(( mCounterTimer = 0 ) ? ( mTime - mTimer / 10 ) : mCounterTimer )
Disabled=1

[mTimer]
Measure=Calc
Formula=(( mCounterTimer = 0 ) ? mTimer : ( mTime - mCounterTimer ) * 10 )

[mSp]
Measure=Calc
Formula=(( mSp + 1 ) % 2 )
Disabled=1
IfAboveValue=0
IfAboveAction=[!DisableMeasure mSp]

[mSm]
Measure=Calc
Formula=(( mSm + 1 ) % 2 )
Disabled=1
IfAboveValue=0
IfAboveAction=[!DisableMeasure mSm]

[mMp]
Measure=Calc
Formula=(( mMp + 1 ) % 2 )
Disabled=1
IfAboveValue=0
IfAboveAction=[!DisableMeasure mMp]

[mMm]
Measure=Calc
Formula=(( mMm + 1 ) % 2 )
Disabled=1
IfAboveValue=0
IfAboveAction=[!DisableMeasure mMm]

[mHp]
Measure=Calc
Formula=(( mHp + 1 ) % 2 )
Disabled=1
IfAboveValue=0
IfAboveAction=[!DisableMeasure mHp]

[mHm]
Measure=Calc
Formula=(( mHm + 1 ) % 2 )
Disabled=1
IfAboveValue=0
IfAboveAction=[!DisableMeasure mHm]

[mTimerSet]
Measure=Calc
Formula=((( mTimerSet + 10 * mSp - 10 * mSm + 600 * mMp - 600 * mMm + 36000 * mHp - 36000 * mHm + #DefaultInitialValue# ) < 0 ) ? ( #DefaultInitialValue# * ( -1 )) : ( mTimerSet + 10 * mSp - 10 * mSm + 600 * mMp - 600 * mMm + 36000 * mHp - 36000 * mHm ))


[mTimer2]
Measure=Calc
Format=%S
Formula=( #DefaultInitialValue# - mTimer + mTimerSet )
IfBelowValue=1
IfBelowAction=[!DisableMeasure mCounterTimer]
MinValue=0
MaxValue=#MaxVal#
DynamicVariables=1

[mTimer3]
Measure=Calc
Formula=(( mCounterTimer = 0 ) ? 1 : ( mTimer2 - 1 ))
IfBelowValue=0
IfBelowAction=[!DisableMeasure mCounterTimer]["#CURRENTPATH#nircmd.exe" #Act#][!HideMeter Stop][!HideMeter Start][!ShowMeter Reset]
DynamicVariables=1

[mTimer4]
Measure=Calc
Formula=(( mCounterTimer = 0 ) ? 1 : ( mTimer2 - 1 ))
IfBelowValue=0
IfBelowAction=[PLAY #Sound#][!HideMeter Stop][!HideMeter Start][!ShowMeter Reset]
DynamicVariables=1

[mTimerHours]
Measure=Calc
Formula=(( FLOOR ( mTimer2 / 36000 )) % 100 )
RegExpSubstitute=1
Substitute="^(.*)$":"0\1","^.*(.{2})$":"\1"

[mTimerMinutes]
Measure=Calc
Formula=(( FLOOR ( mTimer2 / 600 )) % 60 )
RegExpSubstitute=1
Substitute="^(.*)$":"0\1","^.*(.{2})$":"\1"

[mTimerSeconds]
Measure=Calc
Formula=(( FLOOR ( mTimer2 / 10 )) % 60 )
RegExpSubstitute=1
Substitute="^(.*)$":"0\1","^.*(.{2})$":"\1"

;========================================
; METERS
;========================================
[TimerDisplay]
Meter=String
MeterStyle=sAllText
MeasureName=mTimerHours
MeasureName2=mTimerMinutes
MeasureName3=mTimerSeconds
FontSize=16
Text=%1:%2 %3
InlineSetting=Size | 10
InlinePattern=.+( .+)
X=60
Y=20
H=24

;========================================
; Actions
;========================================
[sAction]
StringAlign=Left
FontColor=255,255,255,200
X=r
Y=r

[Action1]
Meter=String
MeterStyle=sAllText | sHighlight | sAction
Text=Hibernate in
X=10
Y=6

[Action2]
Meter=String
MeterStyle=sAllText | sHighlight | sAction
Text=Standby in

[Action3]
Meter=String
MeterStyle=sAllText | sHighlight | sAction
Text=Shutdown in

[Action4]
Meter=String
MeterStyle=sAllText | sHighlight | sAction
Text=Logoff in

[Action5]
Meter=String
MeterStyle=sAllText | sHighlight | sAction
Text=Reboot in

[Action6]
Meter=String
MeterStyle=sAllText | sHighlight | sAction
Text=Snooze in

;========================================
; Controls
;========================================
[sControls]
Group=Controls
Y=45

[Start]
Meter=String
MeterStyle=sAllText | sHighlight | sControls
Text=Start
LeftMouseDownAction=[!SetVariable MaxVal "[mTimer2]"][!EnableMeasure mCounterTimer][!ShowMeter Stop][!HideMeter Start][!HideMeter Reset]
X=25

[Stop]
Meter=String
MeterStyle=sAllText | sHighlight | sControls
Text=Stop
LeftMouseDownAction=[!DisableMeasure mCounterTimer][!HideMeter Stop][!ShowMeter Start][!ShowMeter Reset]
X=25

[Reset]
Meter=String
MeterStyle=sAllText | sHighlight | sControls
Text=Reset
LeftMouseDownAction=[!DisableMeasure mTimer]
LeftMouseUpAction=[!EnableMeasure mTimer][!ShowMeter Start]
X=71

[Set]
Meter=String
MeterStyle=sAllText | sHighlight | sControls
Text=Set
LeftMouseupAction=#HideTimer##ShowSetting#[!SetOption Action1 LeftMouseDownAction """ [!ShowMeter Action2][!HideMeter Action1][!SetVariable Act "Standby"][!EnableMeasure mTimer3][!DisableMeasure mTimer4]"""] [!SetOption Action2 LeftMouseDownAction """ [!ShowMeter Action3][!HideMeter Action2][!SetVariable Act "exitwin poweroff"][!EnableMeasure mTimer3][!DisableMeasure mTimer4]"""] [!SetOption Action3 LeftMouseDownAction """ [!ShowMeter Action4][!HideMeter Action3][!SetVariable Act "exitwin logoff"][!EnableMeasure mTimer3][!DisableMeasure mTimer4]"""] [!SetOption Action4 LeftMouseDownAction """ [!ShowMeter Action5][!HideMeter Action4][!SetVariable Act "exitwin reboot"][!EnableMeasure mTimer3][!DisableMeasure mTimer4]"""] [!SetOption Action5 LeftMouseDownAction """ [!ShowMeter Action6][!HideMeter Action5][!SetVariable Act "hibernate"][!DisableMeasure mTimer3][!EnableMeasure mTimer4]"""] [!SetOption Action6 LeftMouseDownAction """ [!ShowMeter Action1][!HideMeter Action6][!EnableMeasure mTimer3][!DisableMeasure mTimer4]"""][!DisableMeasure mCounterTimer]
X=118

;========================================
; Setting
;========================================
[sSetting]
Hidden=1
Group=SetTimer
Y=45

[HrSetUp]
Meter=String
MeterStyle=sAllText | sHighlight | sSetting
Text=+
LeftMouseDownAction=[!EnableMeasure mHp]
X=25

[HrSetDown]
Meter=String
MeterStyle=sAllText | sHighlight | sSetting
Text=-
LeftMouseDownAction=[!EnableMeasure mHm]
X=35

[MinSetUp]
Meter=String
MeterStyle=sAllText | sHighlight | sSetting
Text=+
LeftMouseDownAction=[!EnableMeasure mMp]
X=55

[MinSetDown]
Meter=String
MeterStyle=sAllText | sHighlight | sSetting
Text=-
LeftMouseDownAction=[!EnableMeasure mMm]
X=65

[SecSetUp]
Meter=String
MeterStyle=sAllText | sHighlight | sSetting
Text=+
LeftMouseDownAction=[!EnableMeasure mSp]
X=85

[SecSetDown]
Meter=String
MeterStyle=sAllText | sHighlight | sSetting
Text=-
LeftMouseDownAction=[!EnableMeasure mSm]
X=95

[OK]
Meter=String
MeterStyle=sAllText | sHighlight | sSetting
Text=OK
LeftMouseupAction=#HideSetting##ShowTimer#[!ShowMeter Reset][!ShowMeter Start][!SetOption Action1 LeftMouseDownAction ""][!SetOption Action2 LeftMouseDownAction ""][!SetOption Action3 LeftMouseDownAction ""][!SetOption Action4 LeftMouseDownAction ""][!SetOption Action5 LeftMouseDownAction ""][!SetOption Action6 LeftMouseDownAction ""][!ShowMeter Start][!ShowMeter Reset][!HideMeter Stop]
X=118

;========================================
; Round Bar
;========================================
[sRoundBar]
LineStart=12
LineLength=16
StartAngle=(Rad(270))
RotationAngle=6.2831853
Antialias=1
Solid=1
X=130
Y=20

[RoundBarBack]
Meter=RoundLine
MeterStyle=sRoundBar
LineColor=255,85,85

[RoundBarFore]
Meter=RoundLine
MeasureName=mTimer2
;MeasureName=mCounterTimer
MeterStyle=sRoundBar
LineColor=128,255,0

;========================================
; Menu
;========================================
;[Menu]
;Meter=IMAGE
;ImageName=;MenuXR.png
;Hidden=1
;X=127
;Y=0
;
;[Close]
;Meter=Shape
;Shape=Rectangle 127,0,20,20,15 | FillColor 200,100,100 | StrokeWidth 2 | Extend StrokeAlpha
;StrokeAlpha=Stroke Color 128,255,0,100
;LeftMouseupAction=!DeactivateConfig
;MouseOverAction=[!SetOption #CURRENTSECTION# StrokeAlpha "Stroke Color 0,255,255,255"] [!UpdateMeter *][!Redraw]
;MouseLeaveAction=[!SetOption #CURRENTSECTION# StrokeAlpha "Stroke Color 128,255,0,100"] [!UpdateMeter *] [!Redraw] 
;DynamicVariables=1
;Hidden=1
;
;[More]
;Meter=Shape
;Shape=Rectangle 127,21,20,20,15 | FillColor 100,100,200 | StrokeWidth 2 | Extend StrokeAlpha
;StrokeAlpha=Stroke Color 128,255,0,100
;LeftMouseupAction=!ActivateConfig "#CURRENTCONFIG#" "Stopwatch.ini"
;MouseOverAction=[!SetOption #CURRENTSECTION# StrokeAlpha "Stroke Color 0,255,255,255"] [!UpdateMeter *][!Redraw]
;MouseLeaveAction=[!SetOption #CURRENTSECTION# StrokeAlpha "Stroke Color 128,255,0,100"] [!UpdateMeter *] [!Redraw] 
;DynamicVariables=1
;Hidden=1
Note that I commented out the MouseOverAction and MouseLeaveAction options of the [Rainmeter] section, not to get error messages whenever are zou hovering the mouse over / leaving the skin.
User avatar
sl23
Posts: 1831
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Simple countdown timer

Post by sl23 »

:welcome:
Last edited by sl23 on September 4th, 2024, 7:04 am, edited 1 time in total.
57686174 77696C6C 6265 77696C6C 6265
User avatar
balala
Rainmeter Sage
Posts: 16651
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Simple countdown timer

Post by balala »

sl23 wrote: July 29th, 2021, 7:40 am Oh damn! I forgot about that max value setting! :oops:

Thanks for the help. I'll have a look later tonight :thumbup:
Ok, please let me know if it does work as expected.
sl23 wrote: July 29th, 2021, 7:40 am So you can use a variable to point to another variable? I thought that, but in my last times skin I couldn't get it to work... Strange!
Not sure what you mean by "variable to point to another variable", but I hope the code (and the Roundline meter) does work.
User avatar
sl23
Posts: 1831
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Simple countdown timer

Post by sl23 »

:welcome:
Last edited by sl23 on September 4th, 2024, 7:05 am, edited 1 time in total.
57686174 77696C6C 6265 77696C6C 6265
User avatar
death.crafter
Rainmeter Sage
Posts: 1398
Joined: April 24th, 2021, 8:13 pm

Re: Simple countdown timer

Post by death.crafter »

sl23 wrote: July 29th, 2021, 9:47 am I meant this...

Code: Select all

[Variables]
DefaultInitialValue=6000
MaxVal=#DefaultInitialValue#
Redundancy.
from the Realm of Death
User avatar
balala
Rainmeter Sage
Posts: 16651
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Simple countdown timer

Post by balala »

sl23 wrote: July 29th, 2021, 9:47 am I meant this...
Oh, I see. Yes, it can be done, however one minor thing you have to take care about is the order of those variables. For instance this is working well:

Code: Select all

[Variables]
DefaultInitialValue=6000
MaxVal=#DefaultInitialValue#
But in the following code, the value of the MaxVal variable is set to #DefaultInitialValue#, not to 6000:

Code: Select all

[Variables]
MaxVal=#DefaultInitialValue#
DefaultInitialValue=6000
User avatar
sl23
Posts: 1831
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Simple countdown timer

Post by sl23 »

:welcome:
Last edited by sl23 on September 4th, 2024, 7:05 am, edited 1 time in total.
57686174 77696C6C 6265 77696C6C 6265