It is currently September 16th, 2019, 11:46 am

Change color of a seperating line from text variable

Help with creating, editing & fixing problems with skins
Sliver
Posts: 6
Joined: May 15th, 2019, 9:57 pm

Change color of a seperating line from text variable

Sliver » August 12th, 2019, 10:51 am

Hello to everyone,

I try to change the color of a bar which works as a separator according to the value of a text variable. I searched a lot but every solution i found (solving similar problems) didn't work for me. Please if you be so kind point me an article or a chunk of code that could help me. My goal is simple. If Text is OK then the bar below would be Green otherwise RED for every [MeterSeperator] according to the value above it.

Code: Select all

[Rainmeter]
Update=500
DynamicWindowSize=1

;Background=Resources/Sidebar.jpg
;BackgroundMode=3
;BackgroundMargins=0,34,0,14

[Variables]
@Include=Machines_State.inc


fontName=Trebuchet MS
textSize=8
colorBar=235,170,0,255
colorText=

;===================Styles==================================
[styleTitle]
StringAlign=Center
StringCase=None
StringStyle=Bold
StringEffect=Shadow
FontEffectColor=0,0,0,50
FontColor=255,255,255,205
FontFace=#fontName#
FontSize=10
AntiAlias=1
ClipString=1

[styleLeftText]
StringAlign=Left
StringCase=None
StringStyle=Bold
StringEffect=Shadow
FontEffectColor=0,0,0,20
FontColor=255,255,255,205
FontFace=#fontName#
FontSize=#textSize#
AntiAlias=1
ClipString=1

[styleRightText]
StringAlign=Right
StringCase=None
StringStyle=Bold
StringEffect=Shadow
FontEffectColor=0,0,0,20
FontColor=255,255,255,205
FontFace=#fontName#
FontSize=#textSize#
AntiAlias=1
ClipString=1

[styleSeperator]
SolidColor=113,203,61,255

;========================================================
;================Labels==================================

[meterTitle]
Meter=String
MeterStyle=styleTitle
FontSize=11
X=100
Y=12
W=190
H=18
Text=Core Stations

[MeterSub_Title]
Meter=String
MeterStyle=styleLeftText
FontSize=10
X=10
Y=40
W=190
H=14
Text=Current State:

[MeterSub_TitleVal]
Meter=String
MeterStyle=styleRightText
FontSize=10
MeasureName=String
X=200
Y=0r
W=190
H=14
Text=#Issue#

[meterSeperator]
Meter=Image
MeterStyle=styleSeperator
X=10
Y=60
W=190
H=1s

[meterAigioLabel]
Meter=String
MeterStyle=styleLeftText
X=10
Y=80
W=190
H=14
Text=Something for X

[meterXLabelVal]
Meter=String
MeterStyle=styleRightText
MeasureName=String
X=200
Y=0r
W=190
H=14
Text=#X#
IfAboveCondition=(Text == Down)
IfTrueAction=[!SetVariable [meterSeperator1] SolidColor "255,255,255"] ; My latest unsuccessful try among plenty!!

[meterSeperator1]
Meter=Image
MeterStyle=styleSeperator
X=10
Y=92
W=190
H=1

[meterYLabel]
Meter=String
MeterStyle=styleLeftText
X=10
Y=100
W=190
H=14
Text=Something for Y

[meterYLabelVal]
Meter=String
MeterStyle=styleRightText
MeasureName=String
X=200
Y=0r
W=190
H=14
Text=#Variable2#


[meterSeperator2]
Meter=Image
MeterStyle=styleSeperator
X=10
Y=112
W=190
H=1s

[meterSAPLabel]
Meter=String
MeterStyle=styleLeftText
X=10
Y=120
W=190
H=14
Text=Server SAP

[meterSAPLabelVal]
Meter=String
MeterStyle=styleRightText
MeasureName=String
X=200
Y=0r
W=190
H=14
Text=#SAP#


[meterSeperator3]
Meter=Image
MeterStyle=styleSeperator
X=10
Y=132
W=190
H=1s

[meterEGILabel]
Meter=String
MeterStyle=styleLeftText
X=10
Y=140
W=190
H=14
Text=Server X

[meterEGILabelVal]
Meter=String
MeterStyle=styleRightText
MeasureName=String
X=200
Y=0r
W=190
H=14
Text=#ServerX#


[meterSeperator4]
Meter=Image
MeterStyle=styleSeperator
X=10
Y=152
W=190
H=1s

[meterIRALabel]
Meter=String
MeterStyle=styleLeftText
X=10
Y=160
W=190
H=14
Text=Server Y

[meterIRALabelVal]
Meter=String
MeterStyle=styleRightText
MeasureName=String
X=200
Y=0r
W=190
H=14
Text=#ServerY#


[meterSeperator5]
Meter=Image
MeterStyle=styleSeperator
X=10
Y=172
W=190
H=1s

[meterInternetLabel]
Meter=String
MeterStyle=styleLeftText
X=10
Y=180
W=190
H=14
Text=Internet

[meterInternetLabelVal]
Meter=String
MeterStyle=styleRightText
MeasureName=String
X=200
Y=0r
W=190
H=14
Text=#Internet#


[meterSeperator6]
Meter=Image
MeterStyle=styleSeperator
X=10
Y=192
W=190
H=1s

[meterDNSLabel]
Meter=String
MeterStyle=styleLeftText
X=10
Y=200
W=190
H=14
Text=DNS

[meterDNSLabelVal]
Meter=String
MeterStyle=styleRightText
MeasureName=String
X=200
Y=0r
W=190
H=14
Text=#DNS#


[meterSeperator7]
Meter=Image
MeterStyle=styleSeperator
X=10
Y=212
W=190
H=1s
Thank you everyone in advance even for spending the time to read my question.
Jim
User avatar
jsmorley
Developer
Posts: 19444
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Change color of a seperating line from text variable

jsmorley » August 12th, 2019, 11:55 am

Something like this?

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Variables]
State1=on
State2=off
State3=off
State4=on

[MeasureState1]
Measure=String
String=#State1#
IfMatch=on
IfMatchAction=[!SetOption MeterSep1 SolidColor "31,255,69,255"][!UpdateMeter MeterSep1][!Redraw]
IfNotMatchAction=[!SetOption MeterSep1 SolidColor "251,28,0,255"][!UpdateMeter MeterSep1][!Redraw]

[MeasureState2]
Measure=String
String=#State2#
IfMatch=on
IfMatchAction=[!SetOption MeterSep2 SolidColor "31,255,69,255"][!UpdateMeter MeterSep2][!Redraw]
IfNotMatchAction=[!SetOption MeterSep2 SolidColor "251,28,0,255"][!UpdateMeter MeterSep2][!Redraw]

[MeasureState3]
Measure=String
String=#State3#
IfMatch=on
IfMatchAction=[!SetOption MeterSep3 SolidColor "31,255,69,255"][!UpdateMeter MeterSep3][!Redraw]
IfNotMatchAction=[!SetOption MeterSep3 SolidColor "251,28,0,255"][!UpdateMeter MeterSep3][!Redraw]

[MeasureState4]
Measure=String
String=#State4#
IfMatch=on
IfMatchAction=[!SetOption MeterSep4 SolidColor "31,255,69,255"][!UpdateMeter MeterSep4][!Redraw]
IfNotMatchAction=[!SetOption MeterSep4 SolidColor "251,28,0,255"][!UpdateMeter MeterSep4][!Redraw]

[MeterState1]
Meter=String
MeasureName=MeasureState1
FontSize=11
FontColor=255,255,255,255
SolidColor=0,0,0,1
StringCase=Proper
AntiAlias=1
Text=State1 is %1

[MeterSep1]
Meter=Image
Y=R
W=100
H=2

[MeterState2]
Meter=String
MeasureName=MeasureState2
Y=4R
FontSize=11
FontColor=255,255,255,255
SolidColor=0,0,0,1
StringCase=Proper
AntiAlias=1
Text=State2 is %1

[MeterSep2]
Meter=Image
Y=R
W=100
H=2

[MeterState3]
Meter=String
MeasureName=MeasureState3
Y=4R
FontSize=11
FontColor=255,255,255,255
SolidColor=0,0,0,1
StringCase=Proper
AntiAlias=1
Text=State3 is %1

[MeterSep3]
Meter=Image
Y=R
W=100
H=2

[MeterState4]
Meter=String
MeasureName=MeasureState4
Y=4R
FontSize=11
FontColor=255,255,255,255
SolidColor=0,0,0,1
StringCase=Proper
AntiAlias=1
Text=State4 is %1

[MeterSep4]
Meter=Image
Y=R
W=100
H=2

1.jpg

https://docs.rainmeter.net/manual/measures/general-options/ifmatchactions/
You do not have the required permissions to view the files attached to this post.
User avatar
balala
Rainmeter Sage
Posts: 8617
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Change color of a seperating line from text variable

balala » August 12th, 2019, 12:01 pm

Sliver wrote:
August 12th, 2019, 10:51 am
I try to change the color of a bar which works as a separator according to the value of a text variable. I searched a lot but every solution i found (solving similar problems) didn't work for me. Please if you be so kind point me an article or a chunk of code that could help me. My goal is simple. If Text is OK then the bar below would be Green otherwise RED for every [MeterSeperator] according to the value above it.
EDIT: Sorry jsmorley, again...

I'm not sure I understood what you want, but if I'm not wrong, you'd like to set the color of those meters which use the [styleSeperator] style, right?
If I am right, then there are some issues:
  • First an IfAboveCondition option doesn't exist. There is an IfCondition and an IfAboveValue / IfAboveAction, but IfAboveCondition no.
  • Secondly, even if there would be a such option, these options are always entirely numeric, you can't use them to work with strings
  • Thirdly all these options belong to measures, they can1t be used onto meters. Simply they don't work on meters.
  • Fourthly to work with strings, you can use the IfMatch options. But to use these options, you have to add some String measures to your code.
So, for instance remove the IfAboveCondition and IfTrueAction options from the [meterXLabelVal] meter and add the following measure:

Code: Select all

[MeasureXLabelVal]
Measure=String
String=#X#
IfMatch=Down
IfMatchAction=[!SetOption meterSeperator1 SolidColor "0,255,0"][!UpdateMeter "meterSeperator1"][!Redraw]
IfNotMatchAction=[!SetOption meterSeperator1 SolidColor "255,0,0"][!UpdateMeter "meterSeperator1"][!Redraw]
DynamicVariabels=1
This measure sets the color of the [meterSeperator1] meter. For similar action to all other separators, you have to add further such String measures.
Had I right? Please try this measure and let me know if you got what you need.
Sliver
Posts: 6
Joined: May 15th, 2019, 9:57 pm

Re: Change color of a seperating line from text variable

Sliver » August 13th, 2019, 6:11 am

Hello to both of you and thank you so much for spending time to answer my question. Both your approaches worked (i tried them both).

So to recap and understand how rainmeter works.
If i want to change something according to some value (and as example i ll use my case) i have to do the following:

Write something:

Code: Select all

[meterTitle]
Meter=String
Text = Something
Then do whatever i want with the variable:

Code: Select all

[MeterSub_TitleVal]
Measure=String
String=#X#
IfMatch=#UP_Value#
IfMatchAction=[!SetOption meterSeperator SolidColor "0,255,0"][!UpdateMeter "meterSeperator"][!Redraw]
IfNotMatchAction=[!SetOption meterSeperator SolidColor "255,0,0"][!UpdateMeter "meterSeperator"][!Redraw]
DynamicVariabels=1
Then "print" my variable:

Code: Select all

[MeterSub_TitleValCH]
Meter=String
Text=#X#
And lastly my separator:

Code: Select all

[meterSeperator]
Meter=Image
MeterStyle=styleSeperator
And if my variable was numeric it would be like this:

Code: Select all

[MeterSub_TitleVal]
Measure=Calc
Formula=#X#
IfAboveValue >= 10
IfAboveAction=[!SetOption meterSeperator SolidColor "0,255,0"][!UpdateMeter "meterSeperator"][!Redraw]
IfNotMatchAction=[!SetOption meterSeperator SolidColor "255,0,0"][!UpdateMeter "meterSeperator"][!Redraw]
DynamicVariabels=1
PS. You both are Rainmeter wizards. Every time i Google something there would be a post from both of you, and for some weird reason it will work like a charm :p :p
Are you guys programmers or something equivalent or you just like it as a hobby?
User avatar
balala
Rainmeter Sage
Posts: 8617
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Change color of a seperating line from text variable

balala » August 13th, 2019, 6:53 am

Sliver wrote:
August 13th, 2019, 6:11 am
Then do whatever i want with the variable:

Code: Select all

[MeterSub_TitleVal]
Measure=String
String=#X#
IfMatch=#UP_Value#
IfMatchAction=[!SetOption meterSeperator SolidColor "0,255,0"][!UpdateMeter "meterSeperator"][!Redraw]
IfNotMatchAction=[!SetOption meterSeperator SolidColor "255,0,0"][!UpdateMeter "meterSeperator"][!Redraw]
DynamicVariabels=1
Right. The !SetOption bang can be used to change an existing option of an existing meter or measure. However you can't change the options of the "special" sections like [Rainmeter] (take care - this is very important!). As you could see, those !SetOption bangs I've posted into the IfMatchAction / IfNotMatchAction options of the [MeasureXLabelVal] String measure (or same way did you into your [MeterSub_TitleVal] measure - here note that although not forbiden, nor a good idea is to name a measure as meter: [MeterSub_TitleVal] is in fact a measure and this can create confusion), are setting the appropriate color for the [meterSeperator1] meter.
Sliver wrote:
August 13th, 2019, 6:11 am
Then "print" my variable:

Code: Select all

[MeterSub_TitleValCH]
Meter=String
Text=#X#
Just note here that depending on what you want to do, the same thing can be achieved into another way as well:

Code: Select all

[MeterSub_TitleValCH]
Meter=String
MeasureName=MeterSub_TitleVal
Text=%1
In this case the String meter shows up the value returned by the [MeterSub_TitleVal] measure, which is the same as #X#.
Sliver wrote:
August 13th, 2019, 6:11 am
And if my variable was numeric it would be like this:

Code: Select all

[MeterSub_TitleVal]
Measure=Calc
Formula=#X#
IfAboveValue >= 10
IfAboveAction=[!SetOption meterSeperator SolidColor "0,255,0"][!UpdateMeter "meterSeperator"][!Redraw]
IfNotMatchAction=[!SetOption meterSeperator SolidColor "255,0,0"][!UpdateMeter "meterSeperator"][!Redraw]
DynamicVariabels=1
The IfNotMatchAction option has nothing to do with IfAboveValue / IfAboveAction. You've mixed those options, I suppose. In fact IfAboveValue doesn't have a negation option (if I can say so), an IfBelowValue / IfEqualValue are required in this case. But try to get used to use instead of these, the IfConditions, which is a much newer option and as such, it's much more versatile and easier to be used. for instance the above measure should look like:

Code: Select all

[MeterSub_TitleVal]
Measure=Calc
Formula=#X#
IfCondition=(#CURRENTSECTION#>=10)
IfTrueAction=[!SetOption meterSeperator SolidColor "0,255,0"][!UpdateMeter "meterSeperator"][!Redraw]
IfFalseAction=[!SetOption meterSeperator SolidColor "255,0,0"][!UpdateMeter "meterSeperator"][!Redraw]
DynamicVariabels=1
In this case the condition is posted explicitly into the IfCondition option and it isn't necessary related to the value of the current measure. You can check any condition, for instance the value of a variable set into any other measure. Not a common procedure, but it does work.
Another advantage of using IfCondition is that there can be added any number of such conditions into a measure. There is no limit for their number.
Sliver wrote:
August 13th, 2019, 6:11 am
Are you guys programmers or something equivalent or you just like it as a hobby?
Me personally am not. But I love how Rainmeter does work. In my opinion, it's far the best piece of software I ever have seen and I love it.
Sliver
Posts: 6
Joined: May 15th, 2019, 9:57 pm

Re: Change color of a seperating line from text variable

Sliver » August 13th, 2019, 8:12 am

Woooooooow balala, just wow

Within a Reply you explained and made me understand how the If (in any form) works. Thank you so much for that. It might sound weird or even stupid that i am saying that, but for some reason although i have read the manuals and other posts here, i could simply not get why is that happening.
balala wrote:
August 13th, 2019, 6:53 am
Me personally am not. But I love how Rainmeter does work. In my opinion, it's far the best piece of software I ever have seen and I love it.
It is a very useful program no doubt. What i am trying to do with the question i asked is to Ping with Python a list of IPs and see if they are Live or Down. Then display that on my screen with green and red bar for obvious reasons. I wrote the Python program and the rainemeter's .ini files in 1 hour and i spent 4 hours trying to change the freaking color!! :? :? :? :? :? :? :?

Thank you once again. I hope in the future i ll be able to answer questions like you both do. From the time i started using rainmeter i have installed it in every laptop or PC i use for various reasons and tasks!!!!!!
User avatar
balala
Rainmeter Sage
Posts: 8617
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Change color of a seperating line from text variable

balala » August 13th, 2019, 11:46 am

Sliver wrote:
August 13th, 2019, 8:12 am
Within a Reply you explained and made me understand how the If (in any form) works. Thank you so much for that. It might sound weird or even stupid that i am saying that, but for some reason although i have read the manuals and other posts here, i could simply not get why is that happening.
No, it doesn't sound nor weird, nor stupid. There might be cases when you can't get it to properly work. This forum is here exactly for those cases.
Sliver wrote:
August 13th, 2019, 8:12 am
It is a very useful program no doubt. What i am trying to do with the question i asked is to Ping with Python a list of IPs and see if they are Live or Down. Then display that on my screen with green and red bar for obvious reasons. I wrote the Python program and the rainemeter's .ini files in 1 hour and i spent 4 hours trying to change the freaking color!! :? :? :? :? :? :? :?
Are you sure there is needed a Python program for this? Rainmeter can natively complete at least partially, such tasks.
Sliver wrote:
August 13th, 2019, 8:12 am
Thank you once again. I hope in the future i ll be able to answer questions like you both do. From the time i started using rainmeter i have installed it in every laptop or PC i use for various reasons and tasks!!!!!!
Don't worry, you will be. Especially if you keep working. What you have to keep in mind is that Rainmeter is extremely versatile and there a lot of details which you have to clarify over time for yourself. The result is that you'll be able to write more and more complex codes, with more and more features. The only trick is the continuous coding.