It is currently March 29th, 2024, 2:59 pm

How to change color of Script Output?

Get help with creating, editing & fixing problems with skins
Bugmenot
Posts: 25
Joined: October 7th, 2016, 9:38 am

How to change color of Script Output?

Post by Bugmenot »

Hi,

is it possible to change the color of a script output? I tried with IfAboveValue=400 and IfAboveAction=!RainmeterSetVariable MeasureColor 0,0,0,0 but its not working. I guess the problem is, that Rainmeter only sees the value just as text and not as number.
If that is the case, is there a way to change the color with Substitute?
So like that Substitute="X":"Y"&FontColor=255,255,255,255

I hope, its understandable.^^
Thanks in advance.

Code: Select all

[Rainmeter]
Update=1000
Background=#@#Background.png
DynamicWindowSize=1
AccurateText=1
BackgroundMode=3
BackgroundMargins=0,34,0,14

[Variables]
MeasureColor=255,255,255,255

[MeasureRun]
Measure=Plugin
Plugin=RunCommand
#Parameter=cscript //nologo #@#Scripts\passwordExpires.vbs
Parameter=powershell -NoLogo #@#Scripts\passwordExpires.ps1
State=Hide
OutputType=ANSI
; RegExpSubstitute=1
; Substitute="Name.*#CRLF#":"","#CRLF#":""
IfAboveValue=400
IfAboveAction=!RainmeterSetVariable MeasureColor 0,0,0,0
IfBelowValue=300
IfBelowAction=!RainmeterSetVariable MeasureColor 200,200,200,200

[MeterRun]
UpdateDivider=-1
Meter=String
FontSize=12
FontColor=255,255,255,255
AntiAlias=1
OutputType=Unicode
Text=Text:
X=55
Y=12
W=200
H=18
OnUpdateAction=[!CommandMeasure MeasureRun "Run"]

[MeterResult]
Meter=String
MeasureName=MeasureRun
Y=7R
FontSize=12
FontColor=#MeasureColor#
X=15
Y=12
W=200
H=18
AntiAlias=1
User avatar
Bananorpion
Posts: 40
Joined: April 16th, 2017, 8:35 pm

Re: How to change color of Script Output?

Post by Bananorpion »

My first guess would be adding DynamicVariables=1 in your [MeterResult] section.

My own method would be replacing [!RainmeterSetVariable MeasureColor xxx] by [!SetOption MeasureColor FontColor xxx], so you don't bother with a 1-use variable.
(I think !RainmeterSetVariable is deprecated, !SetVariable is used now)

Maybe that's on purpose, but with your code, the output color starts with white, then if it goes above 400 or below 300, it will change : it won't go back to white unless you refresh.

Edit: replacing [!RainmeterSetVariable MeasureColor xxx] by [!SetOption MeterResult FontColor xxx]
Last edited by Bananorpion on May 12th, 2017, 1:21 pm, edited 2 times in total.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How to change color of Script Output?

Post by balala »

EDIT: Sorry Bananorpion, you beat me.

Normally it should work and it will do if you add a DynamicVariables=1 option to the [MeterResult] meter. This option is needed, because you set dynamically the value of a variable used by the meter. In such cases, no mater where that dynamically set variable is used, this option is absolutely needed, on the measure or meter which uses it.
A few other comments about the posted code:
  • In the [MeasureRun] measure, you have two Parameter options: one with a # before and the other without. I guess you wanted to comment out the first option, but you have to be careful, in Rainmeter we don't comment out an option with the # character, but with a semicolon (;).
  • !Rainmeter... is a deprecated prefix. It doesn't has to be used long time ago.
  • In the IfAboveAction option you set a transparent color. In the 0,0,0,0 color code, the last number is the transparency (the alpha) of the set color. If it is 0, the color is completely transparent. Are you sure you want to use an invisible color?
  • Usually if you set a background to the skin (through the Background option of the [Rainmeter] section), doesn1t worth to set dynamic window size (through the DynamicWindowSize option of the same [Rainmeter] section), because having a background, the skin will always have the size of that background. You can simply remove the DynamicWindowSize=1 option.
Bugmenot
Posts: 25
Joined: October 7th, 2016, 9:38 am

Re: How to change color of Script Output?

Post by Bugmenot »

I got it like this now, but its still not working. The Color itself is just for testing right now. In the .ps1 file is not even a script right now, its just the blank number, nothing else. But still, no color change.

Code: Select all

[Rainmeter]
Update=1000
Background=#@#Background.png
DynamicWindowSize=1
AccurateText=1
BackgroundMode=3
BackgroundMargins=0,34,0,14

[Variables]
MeasureColor=200,200,200,200

[MeasureRun]
Measure=Plugin
Plugin=RunCommand
#Parameter=cscript //nologo #@#Scripts\passwordExpires.vbs
Parameter=powershell -NoLogo #@#Scripts\passwordExpires.ps1
State=Hide
OutputType=ANSI
; RegExpSubstitute=1
; Substitute="Name.*#CRLF#":"","#CRLF#":""
IfAboveValue=400
IfAboveAction=!SetOption MeasureColor FontColor 0,0,0,0
IfBelowValue=300
IfBelowAction=!SetOption MeasureColor FontColor 255,255,255,255

[MeterRun]
UpdateDivider=-1
Meter=String
FontSize=12
FontColor=255,255,255,255
AntiAlias=1
OutputType=Unicode
Text=Text:
X=55
Y=12
W=200
H=18
OnUpdateAction=[!CommandMeasure MeasureRun "Run"]

[MeterResult]
DynamicVariables=1
Meter=String
MeasureName=MeasureRun
Y=7R
FontSize=12
FontColor=#MeasureColor#
X=15
Y=12
W=200
H=18
AntiAlias=1
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How to change color of Script Output?

Post by balala »

Bugmenot wrote:I got it like this now, but its still not working. The Color itself is just for testing right now. In the .ps1 file is not even a script right now, its just the blank number, nothing else. But still, no color change.
Yeah, because the [MeasureRun] measure, which should change the color of the string meter, doesn't return a number. The IfActions don't work on measures which return strings, as [MeasureRun] does.
For such measures, you should use the IfMatchActions. Problem is that at least what I get right now, is an extremely long string (more lines), I don't see a way to create a proper set of IfMatch options. I'm not sure what the posted command does, so right now at least, I can't say anything relevant.

And even if the original IfActions would work well, they had a problem: the values between 300 and 400 (including 300 and 400) wasn't included anywhere, because IfBelowValue=300 means values up to 300, while IfAboveValue=400 means values above 400. What should happen with values between these two limits?
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: How to change color of Script Output?

Post by jsmorley »

I think the first problem is that the point of !SetOption in this case is to eliminate the need for using a #Variable#. !SetOption is used to just directly set, in this case, the FontColor of the meter. Don't use it to set the value of a variable, that isn't the point, and won't work.

IfAboveAction=!SetOption MeasureColor FontColor 0,0,0,0
IfAboveAction=[!SetOption MeterResult FontColor "0,0,0,0"]
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: How to change color of Script Output?

Post by jsmorley »

I would use the About / Skins panel from the right-click of the Rainmeter tray icon to check the actual string / value that [MeasureRun] is returning.
Bugmenot
Posts: 25
Joined: October 7th, 2016, 9:38 am

Re: How to change color of Script Output?

Post by Bugmenot »

I have changed it to this:

Code: Select all

IfAboveValue=10
IfAboveAction=[!SetOption MeterResult FontColor "0,0,0,0"]
IfBelowValue=10
IfBelowAction=[!SetOption MeterResult FontColor "255,255,255,255"]
The Text Color is now white but it stays white, no matter what the Output is. The actual value in about / skins is 3. So it should not be white, I guess.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: How to change color of Script Output?

Post by jsmorley »

Bugmenot wrote:I have changed it to this:

Code: Select all

IfAboveValue=10
IfAboveAction=[!SetOption MeterResult FontColor "0,0,0,0"]
IfBelowValue=10
IfBelowAction=[!SetOption MeterResult FontColor "255,255,255,255"]
The Text Color is now white but it stays white, no matter what the Output is. The actual value in about / skins is 3. So it should not be white, I guess.
If the value is "3", then yeah, it should be white. 3 is below 10 yes?
Bugmenot
Posts: 25
Joined: October 7th, 2016, 9:38 am

Re: How to change color of Script Output?

Post by Bugmenot »

Iam pretty sure 3 is below 10. But to be really sure i have also tried setting the ifabovevalue to 9 and its still stays white.