It is currently March 28th, 2024, 6:02 pm

How To Toggle Blinking Image Off/On

General topics related to Rainmeter.
Post Reply
User avatar
Cusanus
Posts: 10
Joined: February 7th, 2018, 7:08 am

How To Toggle Blinking Image Off/On

Post by Cusanus »

Hello, Gentleman, am new to Rainmeter. Been having great fun. My first skin has a flashing light (LightBeam2.png). The OnUpdateAction combined with the value of MeasureBlinkString works fine, but I'd like to click on the image and toggle it on/off as it can be distracting (alpha=255 for off). I have NOT found any of the if statements to work. I did manage to use a variable called Toggle to hide/display text by varying from 0 to 1 using LeftMouseUpAction, but have not found a way to switch of the blinking for the image. I thought of using a conditional for #Toggle# to use or skip the blinking ImageAlpha statement, but have failed at many attempts. Any help? Thanks Much in Advance. Al

[Variables]
Toggle=1

[MeasureBlinkString1]
Measure=Calc
Formula=MeasureBlinkString1 = 0 ? 200 : 0
DynamicVariables=1

[MeterBlinkingImage]
Meter=Image
ImageName=#@#Images\LightBeam2.png
LeftMouseUpAction=[!SetVariable Toggle "(1-#Toggle#)"][!UpdateMeter *][!Redraw]
OnUpdateAction=!SetOption MeterBlinkingImage ImageAlpha "[MeasureBlinkString1]"
W=800
H=1000
X=-1r
Y=-999
DynamicVariables=1
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How To Toggle Blinking Image Off/On

Post by balala »

Cusanus wrote:but have not found a way to switch of the blinking for the image.
Add the following Calc measure to your code:

Code: Select all

[MeasureBlinking]
Measure=Calc
Formula=#Toggle#
IfCondition=(#CURRENTSECTION#=0)
IfTrueAction=[!PauseMeasure "MeasureBlinkString1"]
IfFalseAction=[!UnpauseMeasure "MeasureBlinkString1"]
DynamicVariables=1
Initially, when the Toggle variable is equal to 1, the IfCondition is false, so the IfFalseAction option is executed. Its !UnpauseMeasure bang, is unpausing the [MeasureBlinkString1] measure, due to this, it enables the blinking. If you click, the Toggle variable switches to 0 and in this moment, the set IfCondition becomes true, so the IfTrueAction is executes. This one pauses the blinking. On a new click, the Toggle variable is set again to 1 and everything restarts.
Just note that the OnUpdateAction option of the [MeterBlinkingImage] meter seems useless. I'd simply replace it with an ImageAlpha=[MeasureBlinkString1] option.
User avatar
Cusanus
Posts: 10
Joined: February 7th, 2018, 7:08 am

Re: How To Toggle Blinking Image Off/On

Post by Cusanus »

balala wrote:Add the following Calc measure to your code:

Code: Select all

[MeasureBlinking]
Measure=Calc
Formula=#Toggle#
IfCondition=(#CURRENTSECTION#=0)
IfTrueAction=[!PauseMeasure "MeasureBlinkString1"]
IfFalseAction=[!UnpauseMeasure "MeasureBlinkString1"]
DynamicVariables=1
Initially, when the Toggle variable is equal to 1, the IfCondition is false, so the IfFalseAction option is executed. Its !UnpauseMeasure bang, is unpausing the [MeasureBlinkString1] measure, due to this, it enables the blinking. If you click, the Toggle variable switches to 0 and in this moment, the set IfCondition becomes true, so the IfTrueAction is executes. This one pauses the blinking. On a new click, the Toggle variable is set again to 1 and everything restarts.
Just note that the OnUpdateAction option of the [MeterBlinkingImage] meter seems useless. I'd simply replace it with an ImageAlpha=[MeasureBlinkString1] option.
Wow, thanks a ton. I did try various conditionals as documented, but am not good setting up context, new to Rainmeter code this week and not the brightest bulb in the box. The OnUpdateAction gives some control over blinking rate using UpdateDivider=x, but maybe like you say that isn't necessary. Suppose I should have tried your suggestions first, but I'll do that now. -Edit ---> Works like a charm, thanks so much. :17good

Edit again... Sorry, still checking this out. The toggle does work, yes, but it now toggles three states, blinking, no blink with image alpha transparent, no blink opaque, apparently. This is fine in a sense, why not have the projector off or on solid, trouble is it is random whether off or on, so perhaps a minor glitch but will think about this more. :17spot1

OK, finally! Replaced the 1st IfCondition with this one:

IfCondition=(MeasureBlinkString1 > 0) && (#CURRENTSECTION#=0)

Now it always stops while the image is opaque. Finally! I'm learning, slow but...
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How To Toggle Blinking Image Off/On

Post by balala »

Cusanus wrote:Sorry, still checking this out. The toggle does work, yes, but it now toggles three states, blinking, no blink with image alpha transparent, no blink opaque, apparently.
I don't think so. You're right about the fact that theoretically there would be three states, but practically when the image is transparent, you can't click it to stop the blinking. This can be done only when the image is opaque, so the blinking can be stopped only in this case. Finally you have just two possibilities: blinking or the not blinking but opaque image.
If that's not correct in your case, please post the whole code of your skin. Just to can take a look...
Post Reply