It is currently April 20th, 2024, 3:21 am

Simple countdown timer

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

Re: Simple countdown timer

Post by sl23 »

Good to know the update is 1000 in Mirage's Timer.

Of course, if I share any skins from now on, I will credit everyone here, as mostly everyone here has helped in some way with most of my works.

I was just looking at Mirage again and thought about the MouseScrollActions too just before reading your reply above! :D
Sure, feel free to use the idea. Glad it helped spur you on.

May I request you add the ability to pause and resume the Mirage Countdown though. That was the only reason I didn't start with that skin.
Then I may tackle this again but start with the Mirage Timer, if that's ok with you?

Thank you to everyone who helped out here :thumbup: :thumbup: :thumbup:
Until the next time... :o
- MuLab -
User avatar
sl23
Posts: 1140
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Simple countdown timer

Post by sl23 »

Well, that didn't take long! :?

It seems there's one issue remaining, hopefully just the one!

This is the reason I changed from the original Action# Strings to the Button# Shapes.
Basically, a refresh makes #CloseApps# work fine. If I click any other Button#, again it works fine and Hibernates, Shutdown or Locks the PC, but click on Button1 to set the Variable back to #CloseApps# and it doesn't change. What this means is that whatever was clicked last, say, Button4 #Lock#, remains as the Variable when clicking Button1. Even though Button1 is clearly stated as #CloseApps#. WTF? :twisted:

Here's the latest code:

Code: Select all

[Rainmeter]
Update=50
BackgroundMode=2
SolidColor=0,0,0,1
DynamicWindowSize=1
;MouseOverAction=[!ShowMeterGroup Menu]
;MouseLeaveAction=[!HideMeterGroup Menu]
OnRefreshAction=[!SetOption Button1 FillAlpha "FillColor 128,255,0,255"][!SetVariable Act "#CloseApps#"][!EnableMeasure mTimer3Act][!EnableMeasure mTimer4Alarm]
AccurateText=1

[Metadata]
Name=Countdown Timer
Author=zzeneg & balala, Yincognito, eclectic tech, death crafter, jsmorley
Information=Based on balala's CountdownTimer, but heavily edited with some added features.
Version=2021.8.1

========================================
; Background
========================================
[Bg]
Meter=Shape
Shape=Rectangle 1,1,220,65,5 | Fill Color 0,0,0,130 | StrokeWidth 2 | Extend StrokeAlpha
StrokeAlpha=Stroke Color 255,255,255,60
MouseOverAction=[!SetOption #CURRENTSECTION# StrokeAlpha "Stroke Color 0,255,255,255"][!UpdateMeter *][!Redraw]
MouseLeaveAction=[!SetOption #CURRENTSECTION# StrokeAlpha "Stroke Color 255,255,255,60"][!UpdateMeter *][!Redraw]
DynamicVariables=1
Padding=5,5,5,5

[Variables]
Alarm=Alarm.wav

DefaultTime=100
MaxVal=#DefaultTime#
;DefaultTime is the time (6000=10mins in one-tenth of seconds!) which appears when you refresh the skin. 

CloseApps=!CommandMeasure mClose "Run"
APP1=Dolphin.exe
APP2=pcsx2.exe
APP3=rpcs3.exe
APP4=retroarch.exe
APP5=

Hibernate=rundll32.exe powrprof.dll,SetSuspendState
Shutdown=shutdown.exe -s -t 5 -f
Lock=rundll32.exe user32.dll, LockWorkStation

Act=#CloseApps#

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

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

[mClose]
Measure=Plugin
Plugin=RunCommand
Program=PowerShell
Parameter=taskkill /IM #APP1#;taskkill /IM #APP2#;taskkill /IM #APP3#;taskkill /IM #APP4#;taskkill /IM #APP5#

========================================
; 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 + #DefaultTime# ) < 0 ) ? ( #DefaultTime# * ( -1 )) : ( mTimerSet + 10 * mSp - 10 * mSm + 600 * mMp - 600 * mMm + 36000 * mHp - 36000 * mHm ))
OnChangeAction=[!SetVariable MaxVal (#DefaultTime#-[mTimer:]+[mTimerSet:])]
DynamicVariables=1

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

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

[mTimer4Alarm]
Measure=Calc
Formula=(( mCounterTimer = 0 ) ? 1 : ( mTimer2 - 1 ))
IfBelowValue=0
IfBelowAction=[PLAY #Alarm#][!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"

========================================
; Timers
========================================
[sTimerDisplay]
FontSize=16
Group=TimerDisplay

[TimerDisplayHr]
Meter=String
MeterStyle=sAllText | sTimerDisplay
MeasureName=mTimerHours
Text=%1:
MouseScrollUpAction=
MouseScrollDownAction=
X=45
Y=25

[TimerDisplayMin]
Meter=String
MeterStyle=sAllText | sTimerDisplay
MeasureName=mTimerMinutes
Text=%1
MouseScrollUpAction=
MouseScrollDownAction=
X=28r
Y=r

[TimerDisplaySec]
Meter=String
MeterStyle=sAllText | sTimerDisplay
MeasureName=mTimerSeconds
FontSize=10
Text=%1
InlineSetting=Size | 10
InlinePattern=.+( .+)
;MouseScrollUpAction=[!EnableMeasure mSp] [!Redraw]
;MouseScrollDownAction=[!EnableMeasure mSm] [!Redraw]
X=26r
Y=9r

========================================
; Buttons
========================================
[sButton]
Shape=Rectangle 0,0,10,10,50 | Extend FillAlpha | StrokeWidth 2 | Extend StrokeAlpha
FillAlpha=FillColor 200,100,100
StrokeAlpha=StrokeColor 128,255,0,0
MouseOverAction=[!SetOption #CURRENTSECTION# StrokeAlpha "StrokeColor 255,255,0,255"] [!UpdateMeter *][!Redraw]
MouseLeaveAction=[!SetOption #CURRENTSECTION# StrokeAlpha ""] [!UpdateMeter *] [!Redraw] 
DynamicVariables=1
Group=Button
Hidden=1
UpdateDivider=-1
X=20r
Y=0r

[Button1]
Meter=Shape
MeterStyle=sButton
LeftMouseUpAction=[!SetOptionGroup Button FillAlpha "FillColor 200,100,100"][!SetOption #CURRENTSECTION# FillAlpha "FillColor 128,255,0,255"][!SetVariable Act "#CloseApps#"][!EnableMeasure mTimer3Act][!EnableMeasure mTimer4Alarm] [!UpdateMeter *][!Redraw]
ToolTipText=Close Apps
X=15
Y=12

[Button2]
Meter=Shape
MeterStyle=sButton
LeftMouseUpAction=[!SetOptionGroup Button FillAlpha "FillColor 200,100,100"][!SetOption #CURRENTSECTION# FillAlpha "FillColor 128,255,0,255"][!SetVariable Act "#Hibernate#"][!EnableMeasure mTimer3Act][!DisableMeasure mTimer4Alarm] [!UpdateMeter *][!Redraw]
ToolTipText=Hibernate

[Button3]
Meter=Shape
MeterStyle=sButton
LeftMouseUpAction=[!SetOptionGroup Button FillAlpha "FillColor 200,100,100"][!SetOption #CURRENTSECTION# FillAlpha "FillColor 128,255,0,255"][!SetVariable Act "#Shutdown#"][!EnableMeasure mTimer3Act][!DisableMeasure mTimer4Alarm] [!UpdateMeter *][!Redraw]
ToolTipText=Shutdown

[Button4]
Meter=Shape
MeterStyle=sButton
LeftMouseUpAction=[!SetOptionGroup Button FillAlpha "FillColor 200,100,100"][!SetOption #CURRENTSECTION# FillAlpha "FillColor 128,255,0,255"][!SetVariable Act "#Lock#"][!EnableMeasure mTimer3Act][!DisableMeasure mTimer4Alarm] [!UpdateMeter *][!Redraw]
ToolTipText=Lock

[Button5]
Meter=Shape
MeterStyle=sButton
LeftMouseUpAction=[!SetOptionGroup Button FillAlpha "FillColor 200,100,100"][!SetOption #CURRENTSECTION# FillAlpha "FillColor 128,255,0,255"][!SetVariable Act ""][!EnableMeasure mTimer3Act][!DisableMeasure mTimer4Alarm] [!UpdateMeter *][!Redraw]
ToolTipText=Off

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

[Start]
Meter=String
MeterStyle=sAllText | sHighlight | sControls
Text=Start
LeftMouseDownAction=[!EnableMeasure mCounterTimer][!HideMeter Start][!ShowMeter Stop][!HideMeter Reset][!HideMeter Set][!SetOptionGroup TimerDisplay FontColor "255,255,0"]
X=30

[Stop]
Meter=String
MeterStyle=sAllText | sHighlight | sControls
Text=Stop
LeftMouseDownAction=[!DisableMeasure mCounterTimer][!HideMeter Stop][!ShowMeter Start][!ShowMeter Reset][!ShowMeter Set][!SetOptionGroup TimerDisplay FontColor ""]
Hidden=1
X=30

[Reset]
Meter=String
MeterStyle=sAllText | sHighlight | sControls
Text=Reset
LeftMouseDownAction=[!DisableMeasure mTimer]
LeftMouseUpAction=[!EnableMeasure mTimer][!ShowMeter Start][!ShowMeter Set][!HideMeter Reset][PlayStop "#Alarm#"][!SetOptionGroup TimerDisplay FontColor ""]
Hidden=1
X=76

[Set]
Meter=String
MeterStyle=sAllText | sHighlight | sControls
Text=Set
LeftMouseUpAction=[!HideMeterGroup Controls][!ShowMeter OK]   [!DisableMeasure mCounterTimer]   [!SetOptionGroup TimerDisplay MeterStyle "sAllText | sHighlight | sTimerDisplay"][!SetOptionGroup Button Hidden "0"]   [!SetOption TimerDisplayHr MouseScrollUpAction """ [!EnableMeasure mHp]"""]   [!SetOption TimerDisplayHr MouseScrollDownAction """ [!EnableMeasure mHm]"""]   [!SetOption TimerDisplayMin MouseScrollUpAction """ [!EnableMeasure mMp]"""]   [!SetOption TimerDisplayMin MouseScrollDownAction """ [!EnableMeasure mMm]"""] [!UpdateMeter *][!Redraw]
X=123

[OK]
Meter=String
MeterStyle=sAllText | sHighlight | sSetting
Text=OK
LeftMouseupAction=[!HideMeter OK][!ShowMeterGroup Controls]   [!HideMeter Reset][!ShowMeter Start][!HideMeter Stop]   [!SetOptionGroup Button Hidden "1"][!SetOptionGroup TimerDisplay MouseScrollUpAction ""][!SetOptionGroup TimerDisplay MouseScrollDownAction ""]   [!SetOptionGroup TimerDisplay MeterStyle "sAllText | sTimerDisplay"] [!UpdateMeter *][!Redraw]
Hidden=1
X=123
Y=50

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

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

[RoundBarFore]
Meter=RoundLine
MeasureName=mTimer2
MeterStyle=sRoundBar
LineColor=100,100,200
LineWidth=4
Solid=0

========================================
; Menu
========================================
;[Menu]
;Meter=IMAGE
;ImageName=;MenuXR.png
;Hidden=1
;Group=Menu
;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
;Group=Menu
;
;[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
;Group=Menu
EDIT:
Maybe it's to do with this?

Code: Select all

[Button1]
LeftMouseUpAction=.... [!EnableMeasure mTimer3Act][!EnableMeasure mTimer4Alarm] 
Where these two Measures are doing similar things?
EDIT2:
Doesn't seem to be that, or removing #CloseApps# from the Variable: [Button1][!SetVariable Act ""]
- MuLab -
User avatar
Yincognito
Rainmeter Sage
Posts: 7128
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Simple countdown timer

Post by Yincognito »

sl23 wrote: August 1st, 2021, 8:19 pmDoes that require a fast Update rate too? Maybe I should've used that as my starting point?
sl23 wrote: August 1st, 2021, 9:39 pm...the ability to pause and resume...
All you need for such a timer approach is something along these lines:

Code: Select all

[Variables]
; Visuals
Scale=1
ScaleRate=0.1
BackgroundW=220
BackgroundH=65
BackgroundCornerRadius=5
BackgroundColor=0,0,0,130
StrokeW=2
StrokeColor0=255,255,255,60
StrokeColor1=0,255,255,255
StrokeColorIndex=0
FontFace=Aller
FontColor=255,255,255,200
FontSize=16
StringEffect=Shadow
FontEffectColor=0,0,0,150
SolidColor=0,0,0,1
Padding=0
TimeAreaYFactor=0.30
TimeAreaWFactor=0.5
SecondsScale=0.625
; Functionals
DefaultSeconds=10
Seconds=#DefaultSeconds#
Direction=-1
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!"
IfCondition=(#CURRENTSECTION#<=0) && (Sgn(#Direction#)=-1)
IfTrueAction=[!PauseMeasureGroup TimerGroup]
IfConditionMode=1
DynamicVariables=1

---Styles---

[TextStyle]
FontFace=#FontFace#
FontSize=(#FontSize#*#Scale#)
FontColor=#FontColor#
StringEffect=#StringEffect#
FontEffectColor=#FontEffectColor#
SolidColor=#SolidColor#
Padding=(#Padding#*#Scale#),(#Padding#*#Scale#),(#Padding#*#Scale#),(#Padding#*#Scale#)
AntiAlias=1

---Meters---

[Background]
Meter=Shape
Shape=Rectangle ((#StrokeW#/2)*#Scale#),((#StrokeW#/2)*#Scale#),(#BackgroundW#*#Scale#),(#BackgroundH#*#Scale#),(#BackgroundCornerRadius#*#Scale#) | Fill Color #BackgroundColor# | StrokeWidth (#StrokeW#*#Scale#) | Stroke Color [#StrokeColor[#StrokeColorIndex]]
UpdateDivider=-1
MouseOverAction=[!SetVariable StrokeColorIndex (1-#StrokeColorIndex#)][!UpdateMeter *][!Redraw]
MouseLeaveAction=[!SetVariable StrokeColorIndex (1-#StrokeColorIndex#)][!UpdateMeter *][!Redraw]
MouseScrollUpAction=[!SetVariable Scale (Clamp(#Scale#+#ScaleRate#,#ScaleRate#,10))][!UpdateMeter *][!Redraw]
MouseScrollDownAction=[!SetVariable Scale (Clamp(#Scale#-#ScaleRate#,#ScaleRate#,10))][!UpdateMeter *][!Redraw]
DynamicVariables=1

[UptimeText]
Meter=String
MeterStyle=TextStyle
X=(((#BackgroundW#*#TimeAreaWFactor#)/2)*#Scale#)
Y=((#BackgroundH#*#TimeAreaYFactor#)*#Scale#)
W=((#BackgroundW#*#TimeAreaWFactor#)*#Scale#)
FontWeight=700
StringAlign=Center
MeasureName=Uptime
Text=%1
InlineSetting=Size | ((#FontSize#*#SecondsScale#)*#Scale#)
InlinePattern=^.*( .*)$
LeftMouseUpAction=[!TogglePauseMeasureGroup TimerGroup]
MiddleMouseUpAction=[!SetVariable Seconds #DefaultSeconds#][!SetVariable Reset 1][!UnpauseMeasureGroup TimerGroup][!UpdateMeasureGroup TimerGroup][!PauseMeasureGroup TimerGroup][!SetVariable Reset 0][!UpdateMeter *][!Redraw]
DynamicVariables=1
This doesn't have many of the features you need, but really, 2 measures and 1 meter (background one excluded) are all you need for a good starting point if you ever build your own timer skin. ;-) Personally, if I'm going to have to modify any skin that I try in order to reach my goal, I'd rather start fresh and add things to my liking as I progress - but then, that's just me. :confused:

P.S. Scrolling scales the "skin" instead of modifying the DefaultSeconds variable, but left click pauses / resumes the timer while middle click resets it. You control almost everything from [Variables], including the Direction, which basically turns the "timer" into a "stopwatch" if you set DefaultSeconds to 0 and Direction to 1.
Last edited by Yincognito on August 1st, 2021, 10:56 pm, edited 1 time in total.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
sl23
Posts: 1140
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Simple countdown timer

Post by sl23 »

Wow! Thanks I'll look at that tomorrow :thumbup: :D

Yeah I understand how you like to start from scratch, but I really am not that good! :oops:
- MuLab -
User avatar
Yincognito
Rainmeter Sage
Posts: 7128
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Simple countdown timer

Post by Yincognito »

sl23 wrote: August 1st, 2021, 10:42 pmYeah I understand how you like to start from scratch, but I really am not that good! :oops:
Well, there are 2 advantages if one starts from scratch in coding:
- you learn faster, since you try things by yourself
- you don't have to figure out what someone else did in his code
I intentionally let this very basic (apart from the multitude of visual variables that are easy to figure out what they're for), so you can understand easier what's going on.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
sl23
Posts: 1140
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Simple countdown timer

Post by sl23 »

Haha! Funny man! Easier! :???: I get some of it after a quick look but it's getting late here!

One thing though,once the skin reaches zero, it starts counting up, is that intentional?

Actually, would you mind removing all the code for the resizing please, that's really thrown me out! :oops:
- MuLab -
User avatar
Yincognito
Rainmeter Sage
Posts: 7128
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Simple countdown timer

Post by Yincognito »

sl23 wrote: August 1st, 2021, 11:00 pmHaha! Funny man! Easier! :???: I get some of it after a quick look but it's getting late here!
Ok ... MUCH easier then! 8-)
sl23 wrote: August 1st, 2021, 11:00 pmOne thing though,once the skin reaches zero, it starts counting up, is that intentional?
No, it was not - sorry 'bout that. I was posting a different version of the code than what I had on my computer, but I edited my reply earlier to produce the correct result (guess you didn't realize it). Basically, when it reaches 0 it pauses itself, but you can accordingly place your code for shutdown or whatever actions there instead, as I didn't bother with that.
sl23 wrote: August 1st, 2021, 11:00 pmActually, would you mind removing all the code for the resizing please, that's really thrown me out! :oops:
Oh no, I hope you didn't hurt yourself after being thrown out like that... :lol: But ok, your wish was my command, and guess what: I removed everything that made the code look "big", "complicated" and "scary" (scaling, variables, etc.) - now you don't have to worry about the big bad wolf anymore, as the whole thing is precisely 100 lines of code (89 if you count off comments and my usual section group markers). I added the rest of the features in the meantime (plus the "Aller" font), so this does what the old code did (and probably more) while being 4 times shorter. The longer bang sequence in the scroll actions is nothing to worry about, as apart from changing / setting the time according to the mouse position when scrolling over the meter in the formula, it's mostly a replica of the reset code in the middle mouse up action. I let the old code as a "skin variant" for easy comparison:

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
; 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=12
LineLength=16
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=700
MeasureName=Uptime
Text=%1
InlineSetting=Size | 10
InlinePattern=^.*( .*)$
MouseScrollUpAction=[!SetVariable DefaultSeconds (Clamp((#DefaultSeconds#+($MouseX:%$<38?3600:($MouseX:%$<76?60:1))),0,(99*3600+59*60+59)))][!SetVariable Seconds [#DefaultSeconds]][!SetVariable Reset 1][!UnpauseMeasureGroup TimerGroup][!UpdateMeasureGroup TimerGroup][!PauseMeasureGroup TimerGroup][!SetVariable Reset 0][!UpdateMeter *][!Redraw]
MouseScrollDownAction=[!SetVariable DefaultSeconds (Clamp((#DefaultSeconds#-($MouseX:%$<38?3600:($MouseX:%$<76?60:1))),0,(99*3600+59*60+59)))][!SetVariable Seconds [#DefaultSeconds]][!SetVariable Reset 1][!UnpauseMeasureGroup TimerGroup][!UpdateMeasureGroup TimerGroup][!PauseMeasureGroup TimerGroup][!SetVariable Reset 0][!UpdateMeter *][!Redraw]
LeftMouseUpAction=[!TogglePauseMeasureGroup TimerGroup]
MiddleMouseUpAction=[!SetVariable Seconds [#DefaultSeconds]][!SetVariable Reset 1][!UnpauseMeasureGroup TimerGroup][!UpdateMeasureGroup TimerGroup][!PauseMeasureGroup TimerGroup][!SetVariable Reset 0][!UpdateMeter *][!Redraw]
DynamicVariables=1

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

[RoundBarForeground]
Meter=RoundLine
MeterStyle=RoundlineStyle
LineColor=100,100,200,255
LineWidth=4
Solid=0
MeasureName=Uptime
Timer_1.0.0.rmskin
P.S. Each of the four actions in the text meter can of course be moved or replicated in separate "buttons" if you like, they're not set in stone. Let me know if you have any question or you don't understand something. And yeah, you can use / reuse - but not abuse - this code without any issue. What I want is that you understand it. ;-)

EDIT: Damn, I again posted a modified version of the code than you actually need, LOL. The code / skin was set to be a stopwatch instead of a timer (for testing purposes), but I edited my initial post to correct this. It was not a big deal, just changing the DefaultSeconds and Direction variables accordingly in [Variables], but it had to be done - after all, we don't want you to be "thrown off" again by such a minor detail. :D
You do not have the required permissions to view the files attached to this post.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm

Re: Simple countdown timer

Post by death.crafter »

Yincognito wrote: August 2nd, 2021, 2:08 am
I would like it if it didn't change the hours and minutes when seconds change. And some other modifications:

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
DefaultMinutes=00
DefaultHours=00

; Seconds left to pass (for a timer), or seconds passed (for a stopwatch)
Seconds=([#DefaultSeconds]+[#DefaultMinutes]*60+[#DefaultHours]*3600)

; 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]+[#DefaultMinutes]*60+[#DefaultHours]*3600)
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.*)$
DynamicVariables=1

[Hours]
Meter=Image
H=25
W=25
X=25
Y=25
SolidColor=0,0,0,1
MouseScrollUpAction=[!SetVariable Default[#CURRENTSECTION] (Clamp([#DefaultHours]+1,0,99))][!SetVariable Seconds ([#DefaultSeconds]+[#DefaultMinutes]*60+[#DefaultHours]*3600)][!SetVariable Reset 1][!UnpauseMeasureGroup TimerGroup][!UpdateMeasureGroup TimerGroup][!PauseMeasureGroup TimerGroup][!SetVariable Reset 0][!UpdateMeter *][!Redraw]
MouseScrollDownAction=[!SetVariable Default[#CURRENTSECTION] (Clamp([#DefaultHours]-1,0,99))][!SetVariable Seconds ([#DefaultSeconds]+[#DefaultMinutes]*60+[#DefaultHours]*3600)][!SetVariable Reset 1][!UnpauseMeasureGroup TimerGroup][!UpdateMeasureGroup TimerGroup][!PauseMeasureGroup TimerGroup][!SetVariable Reset 0][!UpdateMeter *][!Redraw]
MouseActionCursor=0
DynamicVariables=1

[Minutes]
Meter=Image
X=5R
MouseScrollUpAction=[!SetVariable Default[#CURRENTSECTION] (Clamp([#DefaultMinutes]+1,0,59))][!SetVariable Seconds ([#DefaultSeconds]+[#DefaultMinutes]*60+[#DefaultHours]*3600)][!SetVariable Reset 1][!UnpauseMeasureGroup TimerGroup][!UpdateMeasureGroup TimerGroup][!PauseMeasureGroup TimerGroup][!SetVariable Reset 0][!UpdateMeter *][!Redraw]
MouseScrollDownAction=[!SetVariable Default[#CURRENTSECTION] (Clamp([#DefaultMinutes]-1,0,59))][!SetVariable Seconds ([#DefaultSeconds]+[#DefaultMinutes]*60+[#DefaultHours]*3600)][!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
MouseScrollUpAction=[!SetVariable Default[#CURRENTSECTION] (Clamp([#DefaultSeconds]+1,0,59))][!SetVariable Seconds ([#DefaultSeconds]+[#DefaultMinutes]*60+[#DefaultHours]*3600)][!SetVariable Reset 1][!UnpauseMeasureGroup TimerGroup][!UpdateMeasureGroup TimerGroup][!PauseMeasureGroup TimerGroup][!SetVariable Reset 0][!UpdateMeter *][!Redraw]
MouseScrollDownAction=[!SetVariable Default[#CURRENTSECTION] (Clamp([#DefaultSeconds]-1,0,59))][!SetVariable Seconds ([#DefaultSeconds]+[#DefaultMinutes]*60+[#DefaultHours]*3600)][!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
LeftMouseUpAction=!Refresh
Screenshot 2021-08-02 123152.png
You do not have the required permissions to view the files attached to this post.
from the Realm of Death
User avatar
Yincognito
Rainmeter Sage
Posts: 7128
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Simple countdown timer

Post by Yincognito »

death.crafter wrote: August 2nd, 2021, 7:04 amI would like it if it didn't change the hours and minutes when seconds change.
Well, I wouldn't like it either if the superior value didn't change when the inferior one passed its maximum. :confused: It's like placing stick groups of 10 on the ground: when you reached the 11th, it's already the 2nd group of 10. But then, it's fine either way, I guess it's up to the user's preference, in the end - after all, neither approach is wrong in any way, you can "clamp it" or you can add it. :thumbup:
death.crafter wrote: August 2nd, 2021, 7:04 amAnd some other modifications
Yep, those are welcomed. I was trying to make the code as short as possible while preserving the entire functionality, in order to not scare sl23 with it, so I went for the "all in one" approach. Didn't bother with buttons and all, I let that for the OP to decide (hence mentioning that one can move those actions wherever he likes, buttons included). ;-)
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
sl23
Posts: 1140
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Simple countdown timer

Post by sl23 »

Thanks for taking the time to write (and rewrite) that skin :thumbup:
It looks much simpler now, hopefully I can work alone with out needing help. :oops:

It's just all the calc's and formula's that confuse me, as I don't understand all the code for them. Some of it I do, but then the bits I don't stop me from seeing what's happening. Considering I used to love maths at school, and was pretty good too, that's quite bad! :oops:

Sorry if I had sooo much online presence that you had to write that to get shot of me! :rofl: :rofl:
Really though, thanks for the help.

EDIT: One other thing, how did you get the images for Play, Pause and Reset? Really like those ;-)
- MuLab -