It is currently March 29th, 2024, 3:24 pm

Simple countdown timer

Get help with creating, editing & fixing problems with skins
User avatar
Active Colors
Moderator
Posts: 1251
Joined: February 16th, 2012, 3:32 am
Location: Berlin, Germany

Re: Simple countdown timer

Post by Active Colors »

sl23 wrote: July 1st, 2021, 8:34 pm Back again :Whistle

Can I please get some help creating a simple countdown timer. I've looked at balala's and at JSMorley's code earlier in this thread, but can't seem to get what I want. Balala's skin is great, but I really want it as simple as possible.

Just set say, 90 minutes or 120 minutes in a [Variable] and the skin counts down. I've tried to edit balala's code but it's too much to get my head around! :oops: too bloody tired to think straight! :yawn:

I would like a Meter to show the timer as in balala's skin, or even JSMorley's earlier code, with the end result putting PC into hibernation, which I can do. But all the setting options are unnecessary for me.

Thanks.
https://forum.rainmeter.net/viewtopic.php?p=138560#p138560
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, I did come across this, but was hoping for non-lua code. But now I'm thinking, is the lua part just for the timer counting? So all other functions can be adjusted in the skin.ini? I'll take a look anyway... :thumbup:
- MuLab -
User avatar
Active Colors
Moderator
Posts: 1251
Joined: February 16th, 2012, 3:32 am
Location: Berlin, Germany

Re: Simple countdown timer

Post by Active Colors »

sl23 wrote: July 1st, 2021, 9:04 pm Thanks, I did come across this, but was hoping for non-lua code. But now I'm thinking, is the lua part just for the timer counting? So all other functions can be adjusted in the skin.ini? I'll take a look anyway... :thumbup:
You've said that you've seen jsmorley's code on the first page right in this thread. What did it miss? It is non-lua approach. To turnoff your computer at the end of a countdown just change or add a bang of IfTrueAction:

IfTrueAction=[shutdown.exe -s -hybrid -f -t 00]
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 »

Sorry, I'm not that fluent with coding Rainmeter! I couldn't figure how to turn it into a straightforward countdown.
I've managed to change the TimerNixie skin to what I wanted, and it's pretty easy to use and adjust the code so I'll stick with that, thank you for your time :great:
- MuLab -
User avatar
Active Colors
Moderator
Posts: 1251
Joined: February 16th, 2012, 3:32 am
Location: Berlin, Germany

Re: Simple countdown timer

Post by Active Colors »

sl23 wrote: July 1st, 2021, 9:50 pm Sorry, I'm not that fluent with coding Rainmeter! I couldn't figure how to turn it into a straightforward countdown.
I've managed to change the TimerNixie skin to what I wanted, and it's pretty easy to use and adjust the code so I'll stick with that, thank you for your time :great:
Oh I see what you mean now. Yeah that method would require more changes to the code so it will become more complicated. I think lua method is fine because even if you are not really good at making Rainmeter skins or lua you don't actually need to change anything in lua file itself. Simply plug the script into the code and copy-paste other bits of the skin :thumbup:
If you need any more help with this skin hesitate to ask!
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 »

Thank you for the offer, I think I managed to get what I needed from it:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
LeftMouseUpAction=[PlayStop]
RightMouseUpAction=[PlayStop]

[Bg]
Meter=Shape
Shape=Rectangle Rectangle 1,1,300+20,38,5 | StrokeWidth 1 | Extend StrokeAlpha | Fill Color 0,0,0,100
StrokeAlpha=Stroke Color 128,255,0,100
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
X=1

[Variables]
@Include=TimeSettings.inc
ActionToTake=[PlayLoop Alarm.wav][Shutdown=shutdown.exe -s -t 60 -f]

; Shutdown=shutdown.exe -s -t 60 -f
; HybridShutdown=shutdown.exe /s /hybrid /f /t 60
; Restart=shutdown.exe -r -t 0
; Hibernate=rundll32.exe powrprof.dll,SetSuspendState
; Lock=rundll32.exe user32.dll, LockWorkStation

Alarm=PlayLoop Alarm.wav
AlarmTime=8.05
OffTime=8.15

========================================
; Process
========================================
[mProcessTimerStart]
Measure=Calc
Formula=1
IfCondition=(mProcessRainmeter=1)
IfTrueAction=[!EnableMeasureGroup Timers][!UpdateMeasureGroup Timers][!Redraw]
IfFalseAction=[!DisableMeasureGroup Timers][!UpdateMeasureGroup Timers][!Redraw]

[mProcessRainmeter]
Measure=Plugin
Plugin=Process
ProcessName=Rainmeter.exe

========================================
; Timer Measures
========================================
[mNow]
Measure=Time
Group=Timers
UpdateDivider=-1
Disabled=1

[mTotalSeconds]
Measure=Calc
Group=Timers
Formula=(#TimerHours# * 3600) + (#TimerMinutes# * 60) + #TimerSeconds#
UpdateDivider=-1
Disabled=1

[mTarget]
Measure=Time
Group=Timers
Format=%#m/%#d/%Y %#H:%M:%S
TimeStamp=([mNow:TimeStamp] + [mTotalSeconds])
UpdateDivider=1
Disabled=1
DynamicVariables=1
OnUpdateAction=[!SetVariable Target "[mTarget]"][!UpdateMeasure mLua]

[mLua]
Measure=Script
Group=Timers
ScriptFile=#CURRENTPATH#Timer.lua
IfCondition=mLua <= 0
IfTrueAction=#ActionToTake#
Disabled=1

[mHours]
Measure=Calc
Formula=#TimerHours#
[mMinutes]
Measure=Calc
Formula=#TimerMinutes#
[mSeconds]
Measure=Calc
Formula=#TimerSeconds#

========================================
; TIME
========================================
[Style]
FontFace=Aller
AntiAlias=1
H=26

[mTime]
Measure=Time
Format=%#I.%M %p
IfCondition=(#CURRENTSECTION#=#AlarmTime#)
IfTrueAction=[!HideMeter Action][!ShowMeter Message1][#Alarm#][!Redraw]
IfCondition2=(#CURRENTSECTION#=#OffTime#)
IfTrueAction2=[!HideMeter Action][!HideMeter Message1][!ShowMeter Message2][#ActionToTake#][!Redraw]
Substitute=".":":"

[Time]
Meter=String
MeasureName=mTime
MeterStyle=Style
FontSize=24
FontColor=0,255,255
InlineSetting=Size | 15
InlinePattern=.*( .*)$
X=10
Y=-4

[mSecond]
Measure=Time
Format=%S
MinValue=0
MaxValue=60

[Second]
Meter=Bar
MeasureName=mSecond
BarColor=235,170,0,255
BarOrientation=Horizontal
SolidColor=255,255,255,60
X=r
Y=12R
W=150
H=2

[Action]
Meter=String
MeterStyle=Style
FontColor=235,170,100
FontSize=9
Text=Shutdown in:
X=200
Y=0

[TimerDisplay]
Meter=String
MeasureName=mSeconds
MeasureName2=mMinutes
MeasureName3=mHours
MeterStyle=Style
FontSize=15
FontColor=255,228,110,255
Text=%3h %2m %1s
X=r
Y=13

[Message1]
Meter=String
MeterStyle=Style
FontColor=255,128,0
Text=!! 10 Mins until Shutdown !!
Hidden=1
X=150
Y=0

[Message2]
Meter=String
MeterStyle=Style
FontColor=255,128,0
Text=!! Shutting down Now !!
Hidden=1
X=r
Y=0
It's basically used to restrict my sons PC time :D
PC shuts down after two hours or at 8:15, whichever comes first, with an alarm at 8:05 to allow time to prepare and save stuff.
- MuLab -
User avatar
Mordasius
Posts: 1167
Joined: January 22nd, 2011, 4:23 pm
Location: GMT +8

Re: Simple countdown timer

Post by Mordasius »

sl23 wrote: July 2nd, 2021, 12:00 am It's basically used to restrict my sons PC time :D
I can't help but wonder how long it will take your son to become proficient in modifying Rainmeter skins!
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm

Re: Simple countdown timer

Post by death.crafter »

sl23 wrote: July 2nd, 2021, 12:00 am Thank you for the offer, I think I managed to get what I needed from it:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
LeftMouseUpAction=[PlayStop]
RightMouseUpAction=[PlayStop]

[Bg]
Meter=Shape
Shape=Rectangle Rectangle 1,1,300+20,38,5 | StrokeWidth 1 | Extend StrokeAlpha | Fill Color 0,0,0,100
StrokeAlpha=Stroke Color 128,255,0,100
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
X=1

[Variables]
@Include=TimeSettings.inc
ActionToTake=[PlayLoop Alarm.wav][Shutdown=shutdown.exe -s -t 60 -f]

; Shutdown=shutdown.exe -s -t 60 -f
; HybridShutdown=shutdown.exe /s /hybrid /f /t 60
; Restart=shutdown.exe -r -t 0
; Hibernate=rundll32.exe powrprof.dll,SetSuspendState
; Lock=rundll32.exe user32.dll, LockWorkStation

Alarm=PlayLoop Alarm.wav
AlarmTime=8.05
OffTime=8.15

========================================
; Process
========================================
[mProcessTimerStart]
Measure=Calc
Formula=1
IfCondition=(mProcessRainmeter=1)
IfTrueAction=[!EnableMeasureGroup Timers][!UpdateMeasureGroup Timers][!Redraw]
IfFalseAction=[!DisableMeasureGroup Timers][!UpdateMeasureGroup Timers][!Redraw]

[mProcessRainmeter]
Measure=Plugin
Plugin=Process
ProcessName=Rainmeter.exe

========================================
; Timer Measures
========================================
[mNow]
Measure=Time
Group=Timers
UpdateDivider=-1
Disabled=1

[mTotalSeconds]
Measure=Calc
Group=Timers
Formula=(#TimerHours# * 3600) + (#TimerMinutes# * 60) + #TimerSeconds#
UpdateDivider=-1
Disabled=1

[mTarget]
Measure=Time
Group=Timers
Format=%#m/%#d/%Y %#H:%M:%S
TimeStamp=([mNow:TimeStamp] + [mTotalSeconds])
UpdateDivider=1
Disabled=1
DynamicVariables=1
OnUpdateAction=[!SetVariable Target "[mTarget]"][!UpdateMeasure mLua]

[mLua]
Measure=Script
Group=Timers
ScriptFile=#CURRENTPATH#Timer.lua
IfCondition=mLua <= 0
IfTrueAction=#ActionToTake#
Disabled=1

[mHours]
Measure=Calc
Formula=#TimerHours#
[mMinutes]
Measure=Calc
Formula=#TimerMinutes#
[mSeconds]
Measure=Calc
Formula=#TimerSeconds#

========================================
; TIME
========================================
[Style]
FontFace=Aller
AntiAlias=1
H=26

[mTime]
Measure=Time
Format=%#I.%M %p
IfCondition=(#CURRENTSECTION#=#AlarmTime#)
IfTrueAction=[!HideMeter Action][!ShowMeter Message1][#Alarm#][!Redraw]
IfCondition2=(#CURRENTSECTION#=#OffTime#)
IfTrueAction2=[!HideMeter Action][!HideMeter Message1][!ShowMeter Message2][#ActionToTake#][!Redraw]
Substitute=".":":"

[Time]
Meter=String
MeasureName=mTime
MeterStyle=Style
FontSize=24
FontColor=0,255,255
InlineSetting=Size | 15
InlinePattern=.*( .*)$
X=10
Y=-4

[mSecond]
Measure=Time
Format=%S
MinValue=0
MaxValue=60

[Second]
Meter=Bar
MeasureName=mSecond
BarColor=235,170,0,255
BarOrientation=Horizontal
SolidColor=255,255,255,60
X=r
Y=12R
W=150
H=2

[Action]
Meter=String
MeterStyle=Style
FontColor=235,170,100
FontSize=9
Text=Shutdown in:
X=200
Y=0

[TimerDisplay]
Meter=String
MeasureName=mSeconds
MeasureName2=mMinutes
MeasureName3=mHours
MeterStyle=Style
FontSize=15
FontColor=255,228,110,255
Text=%3h %2m %1s
X=r
Y=13

[Message1]
Meter=String
MeterStyle=Style
FontColor=255,128,0
Text=!! 10 Mins until Shutdown !!
Hidden=1
X=150
Y=0

[Message2]
Meter=String
MeterStyle=Style
FontColor=255,128,0
Text=!! Shutting down Now !!
Hidden=1
X=r
Y=0
It's basically used to restrict my sons PC time :D
PC shuts down after two hours or at 8:15, whichever comes first, with an alarm at 8:05 to allow time to prepare and save stuff.
Bad father :rolmfao:

I am waiting for the day he realizes he can just ctrl + right click and unload that skin to stop his computer from shutting down.
from the Realm of Death
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 »

Mordasius wrote: July 2nd, 2021, 2:48 am I can't help but wonder how long it will take your son to become proficient in modifying Rainmeter skins!
He's only 9 but is a bugger to get off the pc so thought about not giving him the choice! Lol
I wondered the same thing. I'm going to have to hide the app though so he can't dig around and disable it! O.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 »

death.crafter wrote: July 2nd, 2021, 4:57 am Bad father :rolmfao:

I am waiting for the day he realizes he can just ctrl + right click and unload that skin to stop his computer from shutting down.
:Whistle :D
Yeah, I had thought about that, but not much I can do with that one.

Edit
I don't suppose there is an option to disable context menus? Not just per skin but globally.

@JSMorley
Would you consider adding this option? Or maybe just the parts that allow unloading and editing of skins.

I'm at work at present, but is there a way to create a complete context menu but without the option to edit or unload? Maybe this would create the illusion that this is all there is so he wouldn't try the ctrl click lol

Am I the only one that would want such a thing?
- MuLab -