It is currently March 28th, 2024, 10:12 pm

Simple countdown timer

Get help with creating, editing & fixing problems with skins
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Simple countdown timer

Post by balala »

sl23 wrote: July 23rd, 2021, 9:40 pm

Code: Select all

...
IfTrueAction2=[!SetOption TimerDisplay Text "#Message1##CRLF#%1:%2 %3"][#Alarm#][!Redraw]Disabled=1
...
Didn't follow too closely this topic, however I'm not sure what would you like to achieve with the above IfTrueAction2 option. Why the Disabled=1 has been posted after the [!Redraw] bang? Would you like to disable a measure? Which one?
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 »

Copy paste error! :oops: :lol:
It was part of the original Timer code, no idea it's purpose!
- MuLab -
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Simple countdown timer

Post by balala »

sl23 wrote: July 24th, 2021, 7:47 pm Copy paste error! :oops: :lol:
It was part of the original Timer code, no idea it's purpose!
Alright, recommend to remove it, even if doesn't cause troubles.
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 »

I'm trying to get three more things to work on this. I need to adapt the existing timer for use on my own PC. Using the same code but with easier ways of adjusting and start stopping.

1. The plan was to allow start and stop via a toggle using LeftMouseDownAction=[!ToggleMeasureGroup Timers][!UpdateMeasureGroup Timers][!Redraw]. But this just pauses the meters whilst allowing the countdown timers to continue, meaning that when unpaused, the timer display jumps.

2. I'm also trying to use a MouseScrollUpAction to control the Hours, Minutes and Seconds individually when timer is stopped. But I just don't get what I'm supposed to be changing. What I am currently doing doesn't work.

3. Changing serially the methods of shutdown in the [Variables]. I think I'll be ok with this one though.

When my son comes to stay, it's always a hassle getting him off a game, so I'm looking at giving him a timer before the game closes. This part is something I can also do. I know, I know, bad dad! :lol:

Here's the skin code:

Code: Select all

[Rainmeter]
Update=1000
BackgroundMode=2
SolidColor=0,0,0,1
DynamicWindowSize=1
AccurateText=1
LeftMouseUpAction=[PlayStop]
RightMouseUpAction=[PlayStop]

[Bg]
Meter=Shape
Shape=Rectangle Rectangle 1,1,330,38,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
X=1

[Variables]
;ActionToTake=[PlayLoop Alarm.wav][shutdown.exe -s -t 60 -f]
ActionText=Shutdown in:

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

TimerHours=0
TimerMinutes=30
TimerSeconds=0

Alarm=PlayLoop Alarm.wav
AlarmTime=7.05
OffTime=7.15

Message1=!! 10 mins until Shutdown!!
Message2=!! Shutting down Now !!

========================================
; STYLES
========================================
[sAllText]
FontFace=Trebuchet MS
StringStyle=Bold
FontSize=16
FontColor=255,228,110,255
AntiAlias=1
DynamicVariables=1
Group=Timers

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

========================================
; 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

========================================
; TIME
========================================
[Style]
FontFace=Trebuchet MS
AntiAlias=1
H=26

[mTime]
Measure=Time
Format=%#I:%M %p
IfCondition=(#CURRENTSECTION#=#AlarmTime#)
IfTrueAction=[!SetOption TimerDisplay Text "#Message1##CRLF#%1:%2 %3"][#Alarm#][!Redraw]
IfCondition2=(#CURRENTSECTION#=#OffTime#)
IfTrueAction2=[!SetOption TimerDisplay Text "#Message2##CRLF#%1:%2 %3"][#ActionToTake#][!Redraw]

[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=10R
W=150
H=2

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

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

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

[mLua]
Measure=Script
ScriptFile=#CURRENTPATH#Timer.lua
IfCondition=mLua <= 0
IfTrueAction=[!SetOption Action Text "#Message2#"][!Redraw][#ActionToTake#]
IfCondition2=(#CURRENTSECTION#=600)
IfTrueAction2=[!SetOption Action Text "#Message1#"][#Alarm#][!Redraw]
MinValue=0
MaxValue=[&mTotalSeconds]
Group=Timers
DynamicVariables=1
Disabled=1

[mHours]
Measure=Calc
Formula=#TimerHours#
RegExpSubstitute=1
Substitute="^(.*)$":"0\1","^.*(.{2})$":"\1"
[mMinutes]
Measure=Calc
Formula=#TimerMinutes#
RegExpSubstitute=1
Substitute="^(.*)$":"0\1","^.*(.{2})$":"\1"
[mSeconds]
Measure=Calc
Formula=#TimerSeconds#
RegExpSubstitute=1
Substitute="^(.*)$":"0\1","^.*(.{2})$":"\1"

[Action]
Meter=String
MeterStyle=Style
FontSize=9
FontColor=255,228,110,255
Text=#ActionText#
LeftMouseDownAction=[!ToggleMeasureGroup Timers][!UpdateMeasureGroup Timers][!Redraw]
X=170
Y=0

[mAlarm]
Measure=calc
Formula=0
DynamicVariables=1
IfCondition=(mHours = #TimerHours#) && (mMinutes = #TimerMinutes#) && (mSeconds = #TimerSeconds#)
IfTrueAction=[PlayLoop #Alarm#] [!Redraw]
Group=Timers

[HourAlarm]
Meter=String
MeasureName=mHours
MeterStyle=sAllText | sHighlight
Text=%1:
MouseScrollUpAction=[!SetVariable TimerHours (Clamp(#TimerHours#+1,0,23))] [!UpdateMeter #CURRENTSECTION#] [!Redraw]
MouseScrollDownAction=[!SetVariable TimerHours (Clamp(#TimerHours#-1,0,23))] [!UpdateMeter #CURRENTSECTION#] [!Redraw]
X=r
Y=15

[MinuteAlarm]
Meter=String
MeasureName=mMinutes
MeterStyle=sAllText | sHighlight
Text=%1
MouseScrollUpAction=[!SetVariable TimerMinutes (Clamp(#TimerMinutes#+1,0,59))] [!UpdateMeter MinuteAlarm] [!Redraw]
MouseScrollDownAction=[!SetVariable TimerMinutes (Clamp(#TimerMinutes#-1,0,59))] [!UpdateMeter MinuteAlarm] [!Redraw]
X=R
Y=r

[SecondAlarm]
Meter=String
MeasureName=mSeconds
MeterStyle=sAllText | sHighlight
FontSize=10
Text=%1
MouseScrollUpAction=[!SetVariable TimerSeconds (Clamp(#TimerSeconds#+1,0,59))] [!UpdateMeter #CURRENTSECTION#] [!Redraw]
MouseScrollDownAction=[!SetVariable TimerSeconds (Clamp(#TimerSeconds#-1,0,59))] [!UpdateMeter #CURRENTSECTION#] [!Redraw]
X=4R
Y=7r

[sRoundBar1]
LineStart=12
LineLength=16
StartAngle=(Rad(270))
RotationAngle=6.2831853
Antialias=1
Solid=1
X=310
Y=20

[Timer1Round]
Meter=RoundLine
MeterStyle=sRoundBar1
LineColor=255,85,85

[Timer2Round]
Meter=RoundLine
MeasureName=mLua
MeterStyle=sRoundBar1
LineColor=128,255,0

For points 1 + 2, check the sections [Action] , [HourAlarm] , [MinuteAlarm] and [SecondAlarm]
- 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 »

balala wrote: July 24th, 2021, 8:08 pm Alright, recommend to remove it, even if doesn't cause troubles.
Wierd! Removing it now makes the timer count up when I pause it!!! :?
- 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 »

Sorry to bump, but could someone please help?

I'm wondering if I'm expecting too much with my expected functions 1 + 2 above. Are they even possible with the inclusion of the Lua script? I've tried everything and don't understand where the problem lies. I think it's likely a formula, but I have no idea where to start with these! :oops:
- MuLab -
User avatar
Yincognito
Rainmeter Sage
Posts: 7029
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Simple countdown timer

Post by Yincognito »

sl23 wrote: July 26th, 2021, 4:21 pm Sorry to bump, but could someone please help?

I'm wondering if I'm expecting too much with my expected functions 1 + 2 above. Are they even possible with the inclusion of the Lua script? I've tried everything and don't understand where the problem lies. I think it's likely a formula, but I have no idea where to start with these! :oops:
I think it's possible, but then I ALWAYS think stuff is possible. Give me some time and I'll take a look at it. ;-)
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 Yincognito, I was just about to give up! Thinking maybe I should just use balala's Countdown timer if he doesn't mind me editing it?
But if I could get this working, I would be very grateful. :D
- MuLab -
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 24th, 2021, 8:21 pm
A full config including the lua would ave been helpful.

And Idk about the [!ToggleMeasureGroup Timers][!UpdateMeasureGroup Timers]. The first bang doesn't need to measure to update later. It will just disable the measures specified in the group right away.
from the Realm of Death
User avatar
Yincognito
Rainmeter Sage
Posts: 7029
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Simple countdown timer

Post by Yincognito »

death.crafter wrote: July 26th, 2021, 5:06 pm A full config including the lua would ave been helpful.
I guess it's TimerNixie of jsmorley, with the last INI code posted by sl23. At least that's the one I'm looking at, before smoking a cigar... :???:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth