0

I've made a widget that is supposed to tell me what % of my shift is complete, but it's not auto-refreshing so if I want the current value I have to manually refresh the skin. How can I make it auto-refresh?

I've tried setting the Update= manually, adding OnUpdateAction and [!Redraw] and a bunch of other things that I regrettably didn't save since they didn't work so now I can't remember them. (Code below has left out metadata, xy coordinates, and irrelevant variables and values not pertaining to this question such as font settings.)

[Rainmeter]
MiddleMouseDownAction=[!WriteKeyValue Variables OffWorkTime1 #OffWorkTime2#][!WriteKeyValue Variables OffWorkTime2 #OffWorkTime3#][!WriteKeyValue Variables OffWorkTime3 #OffWorkTime4#][!WriteKeyValue Variables OffWorkTime4 #OffWorkTime5#][!WriteKeyValue Variables OffWorkTime5 #OffWorkTime1#][!Refresh]
OnUpdateAction=[!UpdateMeasure MeasurePercElaps][!UpdateMeter MeterPercentDisplay][!WriteKeyValue Variables OffWorkTime1 #OffWorkTime1#][!WriteKeyValue Variables OffWorkTime2 #OffWorkTime2#][!WriteKeyValue Variables OffWorkTime3 #OffWorkTime3#][!WriteKeyValue Variables OffWorkTime4 #OffWorkTime4#][!WriteKeyValue Variables OffWorkTime5 #OffWorkTime5#][!Redraw]
LeftMouseDownAction=[!UpdateMeasure MeasurePercElaps][!UpdateMeter MeterPercentDisplay][!Redraw]
Update=200

[Variables]
OffWorkTime1=870
OffWorkTime2=900
OffWorkTime3=990
OffWorkTime4=1140
OffWorkTime5=1260
HR=[MeasureHour]
MN=[MeasureMin]
PElaps=[MeasurePercElaps:0%]

;MEASURES===================

[MeasureHour]
measure=time
format=%H

[MeasureMin]
measure=time
format=%M

[MeasurePercElaps]
measure=calc
formula=(((540 - (#OffWorkTime1# - ((#HR# * 60) + #MN#))) / 540) * 100)
MinValue=0
MaxValue=100

;METERS===================

[MeterBarPercent]
meter=bar
MeasureName=MeasurePercElaps
W=201
h=23
ValueRemainder=100
BarColor=84,165,196,255
BarOrientation=Horizontal
DynamicVariables=1

[MeterPercentDisplay]
meter=string
MeasureName=MeasurePercElaps
AntiAlias=1
NumOfDecimals=1
DynamicVariables=1
Postfix=% COMPLETE

It should be auto-refreshing every Update cycle, but instead the only way I can get it to refresh the values displayed is by manually refreshing it. It gives the correct value when refreshed, so I know the formulas aren't faulty, but it's just not updating automatically for some reason. The LeftMouseDownAction= thing I put in there doesn't work either. Any pointers you have would be much appreciated.

~δelta

Delta LK
  • 1
  • 4

1 Answers1

1

You need to DynamicVariables=1 under the measure, [MeasurePercElaps] for it to keep updating.

Following script is more or less what are you trying to achieve but I just use a formula to calculate the % seconds left in 1 minute for an immediate effect.

;MEASURES===================

[MeasureHour]
measure=Time
format=%H

[MeasureMin]
measure=Time
format=%M

[MeasureSec]
measure=Time
format=%S

[MeasurePercElaps]
measure=Calc
;formula=(((540 - (#OffWorkTime1# - ((#HR# * 60) + #MN#))) / 540) * 100)
formula=((60.0-[MeasureSec])/60.0)*100.0
MinValue=0
MaxValue=100
DynamicVariables=1

[MeterBarPercent]
meter=Bar
MeasureName=MeasurePercElaps
AntiAlias=1
FontFace=#FontFace#
FontSize=12
SolidColor=47,47,47,255
StringAlign=Left
X=0
Y=0
W=190
H=20
ValueRemainder=100
BarColor=84,165,196,255
BarOrientation=Horizontal
DynamicVariables=1

[MeterPercentDisplay]
meter=String
MeasureName=MeasurePercElaps
AntiAlias=1
FontFace=#FontFace#
FontSize=12
FontColor=255,255,255,255
StringAlign=Left
X=0
Y=0
W=190
AntiAlias=1
NumOfDecimals=1
Postfix=% COMPLETE
DynamicVariables=1

The bar meter should be like below:

enter image description here

Since the [MeasurePercElaps] now can update itself, LeftMouseDownAction in the [Rainmeter] is not needed anymore. If you still put it there, it will lock you from moving the skin anywhere in your desktop area and you won't be able to open the skin's popup menu.

You can keep OnUpdateAction if you need to make your OffWorkTime variables persist on the next skin load/reload. But, I don't see the point, since you are only saving variables that are always constant during the skin session. It is what !WriteKeyValue bang is doing.

On the other hand, MiddleMouseDownAction is quite redundant.

ecle
  • 3,952
  • 1
  • 18
  • 22