Page 2 of 2

Re: Problem with IfMatch

Posted: September 20th, 2022, 8:41 pm
by tass_co
Sorry for interrupting.

I guess the action is requested to be executed when the value in the OFF variable is equal.
(Sorry if I misunderstood)

I made some changes to your code

The format in the OFF variable should be "##:##:##"
I added [] and "" to your Shutdown,Restart,etc variables to make it work.


Code: Select all

[Rainmeter]
Update=1000
AccurateText=1
MouseActionCursor=0
BackgroundMode=2
SolidColor=255,255,255
MouseOverAction=[!ToggleMeterGroup Power] [!UpdateMeter *] [!Redraw]
MouseLeaveAction=[!ToggleMeterGroup Power] [!UpdateMeter *] [!Redraw]
RightMouseUpAction=[!TraMenu]
SkinWidth=150
SkinHeight=55

[Metadata]
Name=Clock + Shutdown
Author=sl23
Information=Clock with Shutdown.||
Version=2022.9.20
License=CC BY 3.0

[Variables]
Black=0,0,0
Trans=0,0,0,1

Shutdown.=250,150,150
Restart.=100,200,100
Sleep.=150,150,250
Lock.=235,170,100

Shutdown=["shutdown.exe" -s -t 00 -f]
;[!Log "Shutdown"]
Restart=["shutdown.exe" -r -t 0]
;[!Log "Restart"]
Sleep=["rundll32.exe" powrprof.dll,SetSuspendState]
;[!Log "Sleep"]
Lock=["rundll32.exe" user32.dll, LockWorkStation]
;[!Log "Lock"]

Startup=["shell:Startup"]
OFF="4:25:00"

========================================
; Time
========================================
[mTime]
Measure=Time
Format=%#I:%M:%S
IfMatch=#OFF#
IfMatchAction=#Sleep#
DynamicVariables=1

[Time]
Meter=String
MeasureName=mTime
FontFace=Trebuchet MS
StringStyle=Bold
StringAlign=CenterCenter
FontSize=25
FontColor=#Black#
;SolidColor=120,120,120
AntiAlias=1
Text=%1

LeftMouseUpAction=[!RefreshApp]
LeftMouseDoubleClickAction=#Startup#
MiddleMouseUpAction=[!Quit]
;ToolTipText="L - Refresh#CRLF#M - Exit"

X=75
Y=20
H=28

========================================
; SHUTDOWN
========================================
[sShut]
Shape=Rectangle 0,0,10,10,5 | Extend FillColor | StrokeWidth 2 | Extend StrokeAlpha
FillColor=Fill Color [#[#CURRENTSECTION]]
StrokeAlpha=Stroke Color #Trans#

MouseOverAction=[!SetOption #CURRENTSECTION# StrokeAlpha "Stroke Color #Black#"] [!UpdateMeter *][!Redraw]
MouseLeaveAction=[!SetOption #CURRENTSECTION# StrokeAlpha ""] [!UpdateMeter *] [!Redraw]
DynamicVariables=1

ToolTipText=#CURRENTSECTION#
Group=Power
Hidden=1
X=15r
Y=r

[Shutdown.]
Meter=Shape
MeterStyle=sShut
LeftMouseUpAction=#Shutdown#
X=-26r
Y=18r

[Restart.]
Meter=Shape
MeterStyle=sShut
LeftMouseUpAction=#Restart#

[Sleep.]
Meter=Shape
MeterStyle=sShut
LeftMouseUpAction=#Sleep#

[Lock.]
Meter=Shape
MeterStyle=sShut
LeftMouseUpAction=#Lock#


Re: Problem with IfMatch

Posted: September 20th, 2022, 9:17 pm
by sl23
Thanks to both of you for your help :thumbup:

I tried tass_co's suggestion first, simply due to less editing involved, and that worked a treat. Thanks for the solution. :welcome: :great:

I'll let you know tomorrow if it worked or not...

Re: Problem with IfMatch

Posted: September 20th, 2022, 10:25 pm
by tass_co
sl23 wrote: September 20th, 2022, 9:17 pm Thanks to both of you for your help :thumbup:

I tried tass_co's suggestion first, simply due to less editing involved, and that worked a treat. Thanks for the solution. :welcome: :great:

I'll let you know tomorrow if it worked or not...
I want to make a correction.
#OFF# should be "4:25:00".
I thought it would show "04:25:00" time but no leading zero "0".
Sorry for that :oops:
21.09.2022 - 01.25.40-About Rainmeter.png

Re: Problem with IfMatch

Posted: September 21st, 2022, 9:38 am
by sl23
:D thanks, already sussed it! :thumbup:

Re: Problem with IfMatch

Posted: September 21st, 2022, 4:02 pm
by sl23
Problem solved, thanks for your help :thumbup:

Re: Problem with IfMatch

Posted: September 21st, 2022, 4:38 pm
by balala
sl23 wrote: September 20th, 2022, 9:17 pm I tried tass_co's suggestion first, simply due to less editing involved, and that worked a treat. Thanks for the solution. :welcome: :great:
Did you try the IfCondition solution? Am just curious...

Re: SOLVED - Problem with IfMatch

Posted: September 21st, 2022, 8:53 pm
by sl23
No I used IfMatch :thumbup:

Re: SOLVED - Problem with IfMatch

Posted: September 22nd, 2022, 12:16 pm
by tass_co
sl23 wrote: September 21st, 2022, 8:53 pm No I used IfMatch :thumbup:
I've realized now :D

If you only want it to execute an action at an hour in the afternoon, we need to add another timer.
I made the solution using AM/PM difference.

Code: Select all

.
.
.
========================================
; Time
========================================
[mTimePM]
Measure=Time
Format=%p%#I:%M:%S
RegExpSubstitute=1
Substitute="PM":""

[mTime]
Measure=Time
Format=%#I:%M:%S
IfMatch=(?=.*#OFF#)([&mTimePM])
IfMatchAction=#Sleep#
DynamicVariables=1
.
.
.
.

22.09.2022 - 07.15.55-About Rainmeter.png

Re: SOLVED - Problem with IfMatch

Posted: September 23rd, 2022, 6:59 am
by sl23
That's really good of you tass_co, thanks, but it's not necessary as the pc won't be on in the morning so it doesn't cause a problem. But it is working fine as is.
Appreciate your continuing thoughts though :thumbup:

Re: SOLVED - Problem with IfMatch

Posted: September 23rd, 2022, 8:14 am
by tass_co
sl23 wrote: September 23rd, 2022, 6:59 am That's really good of you tass_co, thanks, but it's not necessary as the pc won't be on in the morning so it doesn't cause a problem. But it is working fine as is.
Appreciate your continuing thoughts though :thumbup:
:great: