It is currently May 17th, 2024, 1:42 pm

Simple countdown timer

Get help with creating, editing & fixing problems with skins
User avatar
Yincognito
Rainmeter Sage
Posts: 7258
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Simple countdown timer

Post by Yincognito »

death.crafter wrote: August 2nd, 2021, 3:01 pm I didn't separate the uptime text.

I have 3 image meters I use for scrolling(to change hours, minutes and seconds). I just added 8 lines and edited one.

What I am doing is changing the inline pattern on mouse over.

For hour: ^(\d{2})
For minute: ^.*:(\d{2})
For second: ^.*\s(\d{2}) (could be (\d{2})$)
I actually thought the same thing, LOL - except the image part. I wanted to have the same meter repeated and the unwanted parts to be made invisible, then the wanted parts highlighted or not. Your idea is much better, while you surely can avoid messing with the measures, you simply can't avoid the same thing with meters: you HAVE to create new ones. Oh, and the issue I mentioned is corrected as well - good job! :thumbup:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
sl23
Posts: 1146
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Simple countdown timer

Post by sl23 »

Works very well, thanks death.crafter.

@Yincognito: What issue was that?
- MuLab -
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: August 2nd, 2021, 3:22 pm Works very well, thanks death.crafter.

@Yincognito: What issue was that?
Here you go:

Code: Select all

[Variables]
; Background's stroke colors (0 = mouse leave color, 1 = mouse hover color)
StrokeColor0=255,255,255,60
StrokeColor1=0,255,255,255
StrokeColorIndex=0

; The time at which the timer / stopwatch is set or reset, in seconds (>0 for a timer, 0 for a stopwatch)
DefaultSeconds=60

; Max value of timer - 99 hours 59 minutes 59 seconds
MaxValue=359999

; Seconds left to pass (for a timer), or seconds passed (for a stopwatch)
Seconds=[#DefaultSeconds]

; The amount of seconds by which the timer / stopwatch changes (<0 for a timer, >0 for a stopwatch)
Direction=-1

; Temporarily set to 1 when the timer / stopwatch is reset so the OnChangeAction below doesn't alter the Seconds above
Reset=0

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
OnRefreshAction=[!PauseMeasureGroup TimerGroup]

---Measures---

[Time]
Group=TimerGroup
Measure=Time
Format=%H:%M %S
OnChangeAction=[!SetVariable Seconds (#Seconds#+#Direction#*(1-#Reset#))]
DynamicVariables=1

[Uptime]
Group=TimerGroup
Measure=Uptime
SecondsValue=#Seconds#
Format="%3!02i!:%2!02i! %1!02i!"
MaxValue=[#DefaultSeconds]
IfCondition=(#CURRENTSECTION#<=0) && (Sgn(#Direction#)=-1)
IfTrueAction=[!PauseMeasureGroup TimerGroup]
IfConditionMode=1
DynamicVariables=1

---Styles---

[TextStyle]
FontFace=Aller
FontSize=16
FontColor=255,255,255,200
StringEffect=Shadow
FontEffectColor=0,0,0,150
SolidColor=0,0,0,1
Padding=0,0,0,0
AntiAlias=1

[RoundlineStyle]
LineStart=14
LineLength=18
StartAngle=(Rad(270))
Antialias=1
Solid=1
X=160
Y=33

---Meters---

[Background]
Meter=Shape
Shape=Rectangle 1,1,220,65,5 | Fill Color 0,0,0,130 | StrokeWidth 2 | Stroke Color [#StrokeColor[#StrokeColorIndex]]
UpdateDivider=-1
MouseOverAction=[!SetVariable StrokeColorIndex (1-#StrokeColorIndex#)][!UpdateMeter #CURRENTSECTION#][!Redraw]
MouseLeaveAction=[!SetVariable StrokeColorIndex (1-#StrokeColorIndex#)][!UpdateMeter #CURRENTSECTION#][!Redraw]
DynamicVariables=1

[UptimeText]
Meter=String
MeterStyle=TextStyle
X=25
Y=20
FontWeight=650
MeasureName=Uptime
Text=%1
InlineSetting=Size | 10
InlinePattern=^.*(\s.*)$
InlineSetting2=Weight | 800
InlinePattern2=^.*(\s.*)$
InlinePattern3=^$
InlineSetting3=Color | #StrokeColor1#
DynamicVariables=1

[Hours]
Meter=Image
H=25
W=25
X=25
Y=25
SolidColor=0,0,0,1
MouseOverAction=[!SetOption UptimeText InlinePattern3 "^(\d{2})"][!UpdateMeter UptimeText][!Redraw]
MouseLeaveAction=[!SetOption UptimeText InlinePattern3 "^$"][!UpdateMeter UptimeText][!Redraw]
MouseScrollUpAction=[!SetVariable DefaultSeconds (Clamp([#DefaultSeconds]+3600,0,#MaxValue#))][!SetVariable Seconds [#DefaultSeconds]][!SetVariable Reset 1][!UnpauseMeasureGroup TimerGroup][!UpdateMeasureGroup TimerGroup][!PauseMeasureGroup TimerGroup][!SetVariable Reset 0][!UpdateMeter *][!Redraw]
MouseScrollDownAction=[!SetVariable DefaultSeconds (Clamp(([#DefaultSeconds]/3600>=1?[#DefaultSeconds]-3600:[#DefaultSeconds]),0,#MaxValue#))][!SetVariable Seconds [#DefaultSeconds]][!SetVariable Reset 1][!UnpauseMeasureGroup TimerGroup][!UpdateMeasureGroup TimerGroup][!PauseMeasureGroup TimerGroup][!SetVariable Reset 0][!UpdateMeter *][!Redraw]
MouseActionCursor=0
DynamicVariables=1

[Minutes]
Meter=Image
X=5R
MouseOverAction=[!SetOption UptimeText InlinePattern3 "^.*:(\d{2})"][!UpdateMeter UptimeText][!Redraw]
MouseLeaveAction=[!SetOption UptimeText InlinePattern3 "^$"][!UpdateMeter UptimeText][!Redraw]
MouseScrollUpAction=[!SetVariable DefaultSeconds (Clamp([#DefaultSeconds]+60,0,#MaxValue#))][!SetVariable Seconds [#DefaultSeconds]][!SetVariable Reset 1][!UnpauseMeasureGroup TimerGroup][!UpdateMeasureGroup TimerGroup][!PauseMeasureGroup TimerGroup][!SetVariable Reset 0][!UpdateMeter *][!Redraw]
MouseScrollDownAction=[!SetVariable DefaultSeconds (Clamp(([#DefaultSeconds]/60>=1?[#DefaultSeconds]-60:[#DefaultSeconds]),0,#MaxValue#))][!SetVariable Seconds [#DefaultSeconds]][!SetVariable Reset 1][!UnpauseMeasureGroup TimerGroup][!UpdateMeasureGroup TimerGroup][!PauseMeasureGroup TimerGroup][!SetVariable Reset 0][!UpdateMeter *][!Redraw]
MeterStyle=Hours

[Seconds]
Meter=Image
H=22
X=4R
Y=28
MouseOverAction=[!SetOption UptimeText InlinePattern3 "^.*\s(\d{2})"][!UpdateMeter UptimeText][!Redraw]
MouseLeaveAction=[!SetOption UptimeText InlinePattern3 "^$"][!UpdateMeter UptimeText][!Redraw]
MouseScrollUpAction=[!SetVariable DefaultSeconds (Clamp([#DefaultSeconds]+1,0,#MaxValue#))][!SetVariable Seconds [#DefaultSeconds]][!SetVariable Reset 1][!UnpauseMeasureGroup TimerGroup][!UpdateMeasureGroup TimerGroup][!PauseMeasureGroup TimerGroup][!SetVariable Reset 0][!UpdateMeter *][!Redraw]
MouseScrollDownAction=[!SetVariable DefaultSeconds (Clamp([#DefaultSeconds]-1,0,#MaxValue#))][!SetVariable Seconds [#DefaultSeconds]][!SetVariable Reset 1][!UnpauseMeasureGroup TimerGroup][!UpdateMeasureGroup TimerGroup][!PauseMeasureGroup TimerGroup][!SetVariable Reset 0][!UpdateMeter *][!Redraw]
MeterStyle=Hours

[RoundBarBackground]
Meter=RoundLine
MeterStyle=RoundlineStyle
LineColor=255,255,255,20

[RoundBarForeground]
Meter=RoundLine
MeterStyle=RoundlineStyle
LineColor=#StrokeColor1#
LineWidth=4
MeasureName=Uptime

[Play]
Meter=String
FontFace=Segoe MDL2 Assets
Text=[\xE768]
FontSize=12
FontColor=255,255,255,200
X=160
Y=34
FontWeight=600
AntiAlias=1
StringAlign=CenterCenter
Group=PlayPause
LeftMouseUpAction=[!UnpauseMeasureGroup TimerGroup][!ToggleMeterGroup PlayPause][!Redraw]

[Pause]
Meter=String
Text=[\xE769]
Hidden=1
LeftMouseUpAction=[!PauseMeasureGroup TimerGroup][!ToggleMeterGroup PlayPause][!Redraw]
MeterStyle=Play

[Stop]
Meter=String
FontFace=Segoe MDL2 Assets
Text=[\xE72C]
FontSize=11
FontColor=255,255,255,200
X=190
Y=34
FontWeight=600
AntiAlias=1
StringAlign=LeftCenter
DynamicVariables=1
LeftMouseUpAction=[!WriteKeyValue Variables DefaultSeconds [#DefaultSeconds]][!Refresh]
I also corrected Yin's error. If hour is 00, scrolling on it won't make the minutes and seconds 00. Same for minutes. When it's 00:00 scrolling on both won't make seconds 00.
from the Realm of Death
User avatar
sl23
Posts: 1146
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Simple countdown timer

Post by sl23 »

Tbh, I didn't find that I had that issue. I tried scrolling up and down on the 00 and it didn't affect anything else? Strange!

What did you change in the code?
- MuLab -
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: August 2nd, 2021, 3:54 pm Tbh, I didn't find that I had that issue. I tried scrolling up and down on the 00 and it didn't affect anything else? Strange!

What did you change in the code?
You want it to be that way?

I mean if it's 00:07 40, scrolling down on the hour makes it 00:00 00.

I corrected this to work properly.

When you scroll on hour part nothing will happen if it's 00. Same for minute.
from the Realm of Death
User avatar
sl23
Posts: 1146
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Simple countdown timer

Post by sl23 »

No. Definitely not! :o
But it doesn't do that for me anyway. I mean that it works correctly without that issue. What did you change to fix it your end?
Last edited by sl23 on August 2nd, 2021, 4:18 pm, edited 1 time in total.
- MuLab -
User avatar
Yincognito
Rainmeter Sage
Posts: 7258
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Simple countdown timer

Post by Yincognito »

death.crafter wrote: August 2nd, 2021, 3:27 pmI also corrected Yin's error. If hour is 00, scrolling on it won't make the minutes and seconds 00. Same for minutes. When it's 00:00 scrolling on both won't make seconds 00.
I repeat myself: that is NOT an "error" - it's the intended and expected behavior. If someone (anyone) doesn't like it, that doesn't make it an "error", you know - some like white chocolate, some like black chocolate, and neither of them is making an error to do that. :confused:

So, when it's 00:00:47, I'm on the minute and I scroll downwards, that means "subtract a minute from this". Since you can't have negative times, there are 2 choices, equally valid:
- don't do anything, if you're expected to scroll seconds instead, in order to modify them (your way)
- subtract the most you can to get as close as subtracting a minute as possible, i.e. the 47 seconds (my way)
The latter is consistent with my general approach of being able to modify the minutes even if you scroll on seconds, and the hours if you scroll on either minutes or seconds long enough. Since I use an Uptime measure, it's all about seconds to me - and incidentally, it's the same for Windows or any clock whatsoever, because when you reach 60 seconds on a clock or a stopwatch, it will automatically increment the minute, and make it 00:01:00. Who says you can't do this backwards? :???:
Last edited by Yincognito on August 2nd, 2021, 4:22 pm, edited 1 time in total.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
sl23
Posts: 1146
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Simple countdown timer

Post by sl23 »

It works just fine the way it is. I can understand some might prefer scrolling hours adjusts minutes etc but I prefer how it is now, thank you.
- MuLab -
User avatar
sl23
Posts: 1146
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Simple countdown timer

Post by sl23 »

I think what death.crafter is saying is that if you scroll it sets the timer to zero?
- MuLab -
User avatar
death.crafter
Rainmeter Sage
Posts: 1398
Joined: April 24th, 2021, 8:13 pm

Re: Simple countdown timer

Post by death.crafter »

Yincognito wrote: August 2nd, 2021, 4:17 pm Since I use an Uptime measure, it's all about seconds to me - and incidentally, it's the same for Windows or any clock whatsoever, because when you reach 60 seconds on a clock or a stopwatch, it will automatically increment the minute, and make it 00:01:00. Who says you can't do this backwards? :???:
I beg to differ. I know you are trying to say that none of us is wrong. But still it doesn't sit right in my mind.

You referred to Windows timer and let's go for that.

If you are SETTING the timer, the hour, minute and seconds change irrespective of each other. That is my first remodeling of your code. How the timer works is irrespective of how it is set.

If the time is 00:30 00 then I can't subtract an hour from it. Subtracting the maximum value you can, is just illogical to me.

But then again, each to his own leaf.
from the Realm of Death