It is currently May 6th, 2024, 11:03 am

Using Substitute To Determine if another Measure Is Showing a "1" Value

Get help with creating, editing & fixing problems with skins
User avatar
CodeCode
Posts: 1367
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Using Substitute To Determine if another Measure Is Showing a "1" Value

Post by CodeCode »

Hello,
So I am Doing stuff...
I have Two Measure=Plugin Plugin=Process going. Sometimes it is nice to have choices...

I am trying to find a way for the second Process Measure to recognise when the first Process Measure is having a "1" result or a "-1".

These are my Process Measures: (And how I tried and failed to succeed in my goal so far...)

Code: Select all

[MeasureProcessTopOne]
Measure=Plugin
Plugin=Process
ProcessName=vlc.exe
Substitute="-1":" ","1":" Video Lan Running "

[MeasureProcessTopTwo]
Measure=Plugin
Plugin=Process
ProcessName=
Substitute="-1":" ","1":"Something is Running "," ":"This House Is Clean  ","[MeasureProcessTopOne]":" "
and the String Meter for reference:

Code: Select all

[ProcessTextTop]
Meter=String
MeasureName=MeasureProcessTopOne
MeasureName2=MeasureProcessTopTwo
X=0
Y=0
StringAlign=Center
Text=" %1 %2"
StringCase=Proper
FontColor=200,200,200
FontFace=Calibri
FontSize=16
AntiAlias=1
SolidColor=0,0,0,1
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Using Substitute To Determine if another Measure Is Showing a "1" Value

Post by jsmorley »

I don't really follow what you are trying to do.

[MeasureProcessTopTwo] is always going to return -1, as it doesn't have any process name associated with it.
User avatar
Yincognito
Rainmeter Sage
Posts: 7205
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Using Substitute To Determine if another Measure Is Showing a "1" Value

Post by Yincognito »

CodeCode wrote: October 26th, 2020, 2:01 pm Hello,
So I am Doing stuff...
I have Two Measure=Plugin Plugin=Process going. Sometimes it is nice to have choices...

I am trying to find a way for the second Process Measure to recognise when the first Process Measure is having a "1" result or a "-1".

These are my Process Measures: (And how I tried and failed to succeed in my goal so far...)

Code: Select all

[MeasureProcessTopOne]
Measure=Plugin
Plugin=Process
ProcessName=vlc.exe
Substitute="-1":" ","1":" Video Lan Running "

[MeasureProcessTopTwo]
Measure=Plugin
Plugin=Process
ProcessName=
Substitute="-1":" ","1":"Something is Running "," ":"This House Is Clean  ","[MeasureProcessTopOne]":" "
and the String Meter for reference:

Code: Select all

[ProcessTextTop]
Meter=String
MeasureName=MeasureProcessTopOne
MeasureName2=MeasureProcessTopTwo
X=0
Y=0
StringAlign=Center
Text=" %1 %2"
StringCase=Proper
FontColor=200,200,200
FontFace=Calibri
FontSize=16
AntiAlias=1
SolidColor=0,0,0,1
There is some redundancy in your code above. Why not just perform the needed substitutes in the 1st measure and get rid of the 2nd, if you only want the running status of VLC / something / nothing to be monitored? :confused:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
CodeCode
Posts: 1367
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Re: Using Substitute To Determine if another Measure Is Showing a "1" Value

Post by CodeCode »

jsmorley wrote: October 26th, 2020, 2:06 pm I don't really follow what you are trying to do.

[MeasureProcessTopTwo] is always going to return -1, as it doesn't have any process name associated with it.
Well, I meant for either condition to be recognised. I did not put a process as I thought it was obvious that if the value of [MeasureProcessTopOne] is 1 then [MeasureProcessTopTwo] would substitute itself to be empty string so that both would not be showing at the same time.

I hope I clarified, since my first try was ambiguous?
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
User avatar
CodeCode
Posts: 1367
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Re: Using Substitute To Determine if another Measure Is Showing a "1" Value

Post by CodeCode »

Yincognito wrote: October 26th, 2020, 2:29 pm There is some redundancy in your code above. Why not just perform the needed substitutes in the 1st measure and get rid of the 2nd, if you only want the running status of VLC / something / nothing to be monitored? :confused:
I sort of wrote those measures and meter on the fly as my original code has a crap load of variables.

Sorry it turned out looking sloppy.

See my previous reply for a hopefully better explanation of my problem.
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Using Substitute To Determine if another Measure Is Showing a "1" Value

Post by jsmorley »

Sorry, no. I just don't follow at all.

[MeasureProcessTopTwo] is always going to return -1, and thus have a substituted string value of a space, as it doesn't have any process name associated with it. Nothing about it is going to know or give a hoot what the value of [MeasureProcessTopOne] is...
User avatar
CodeCode
Posts: 1367
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Re: Using Substitute To Determine if another Measure Is Showing a "1" Value

Post by CodeCode »

Code: Select all

[MeasureProcessTopOne]
Measure=Plugin
Plugin=Process
ProcessName=vlc.exe
Substitute="-1":" ","1":" Video Lan Running "

[MeasureProcessTopTwo]
Measure=Plugin
Plugin=Process
ProcessName=qbittorrent.exe
Substitute="-1":" ","1":"qBit Running "," ":"This House Is Clean  ","[color=red][MeasureProcessTopOne]=1[/color]:""
Ok, so now the above represents my scenario - I hope...

If [MeasureProcessTopOne] equals 1, then [MeasureProcessTopTwo] will need, in my goal, to be "nullified" to be an empty string : "" <- like so.

The red part is what I am trying to figure out - it is not the correct code since I do not know what to put there it is just a "filler" for what really needs to be there.
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Using Substitute To Determine if another Measure Is Showing a "1" Value

Post by jsmorley »

CodeCode wrote: October 26th, 2020, 2:52 pm

Code: Select all

[MeasureProcessTopOne]
Measure=Plugin
Plugin=Process
ProcessName=vlc.exe
Substitute="-1":" ","1":" Video Lan Running "

[MeasureProcessTopTwo]
Measure=Plugin
Plugin=Process
ProcessName=qbittorrent.exe
Substitute="-1":" ","1":"qBit Running "," ":"This House Is Clean  ","[color=red][MeasureProcessTopOne]=1[/color]:""
Ok, so now the above represents my scenario - I hope...

If [MeasureProcessTopOne] equals 1, then [MeasureProcessTopTwo] will need, in my goal, to be "nullified" to be an empty string : "" <- like so.

The red part is what I am trying to figure out - it is not the correct code since I do not know what to put there it is just a "filler" for what really needs to be there.
Sorry, no. I just don't get it.

There is just no way that [MeasureProcessTopTwo], a Process plugin measure, can ever know anything about what the value of [MeasureProcessTopOne] is. Substitute isn't a way to ask any question about any measure except the one it is on. Substitute, at its core, is always saying "take a look at the string value of THIS measure, and act on that."

You can use a Calc measure to evaluate the value(s) of both measures, and use IfCondition to drive the Text option (or FontColor, or whatever) on a String meter if you want. Just forget about the Substitute(s) on the two measures.

Code: Select all

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

[Variables]

[MeasureProcessTopOne]
Measure=Plugin
Plugin=Process
ProcessName=vlc.exe

[MeasureProcessTopTwo]
Measure=Plugin
Plugin=Process
ProcessName=qbittorrent.exe

[MeasureEval]
Measure=Calc
Formula=1
IfCondition=(MeasureProcessTopOne = 1) && (MeasureProcessTopTwo = -1)
IfTrueAction=[!SetOption MeterResult Text "vlc is running and qbittorrent isn't"][!UpdateMeter *][!Redraw]
IfCondition2=(MeasureProcessTopOne = -1) && (MeasureProcessTopTwo = -1)
IfTrueAction2=[!SetOption MeterResult Text "Neither is running"][!UpdateMeter *][!Redraw]
IfCondition3=(MeasureProcessTopOne = -1) && (MeasureProcessTopTwo = 1)
IfTrueAction3=[!SetOption MeterResult Text "qbittorrent is running and vlc isn't"][!UpdateMeter *][!Redraw]

[MeterResult]
Meter=String
FontSize=12
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Note that you don't absolutely need the separate Calc measure, as you can stick the IfCondition(s) directly on the [MeasureProcessTopTwo] measure if you want. I used the Calc measure mostly to make it clear that unlike Substitute/IfEqual/IfMatch, the IfCondition(s) are NOT about the measure they are on, but can easily reference and evaluate the values of multiple measures.
User avatar
Yincognito
Rainmeter Sage
Posts: 7205
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Using Substitute To Determine if another Measure Is Showing a "1" Value

Post by Yincognito »

CodeCode wrote: October 26th, 2020, 2:52 pm

Code: Select all

[MeasureProcessTopOne]
Measure=Plugin
Plugin=Process
ProcessName=vlc.exe
Substitute="-1":" ","1":" Video Lan Running "

[MeasureProcessTopTwo]
Measure=Plugin
Plugin=Process
ProcessName=qbittorrent.exe
Substitute="-1":" ","1":"qBit Running "," ":"This House Is Clean  ","[color=red][MeasureProcessTopOne]=1[/color]:""
Ok, so now the above represents my scenario - I hope...

If [MeasureProcessTopOne] equals 1, then [MeasureProcessTopTwo] will need, in my goal, to be "nullified" to be an empty string : "" <- like so.

The red part is what I am trying to figure out - it is not the correct code since I do not know what to put there it is just a "filler" for what really needs to be there.
I think the last jsmorley reply provides the answer to this, but just so you know, you can do pretty much the same using an IfMatch on a "merged" / "concatenated" string between the 2 Process measures (obviously, the measure merging things would have to be a String one). In this case though, I think IfConditions are simpler to handle.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
CodeCode
Posts: 1367
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Re: Using Substitute To Determine if another Measure Is Showing a "1" Value

Post by CodeCode »

jsmorley wrote: October 26th, 2020, 3:30 pm Sorry, no. I just don't get it.

There is just no way that [MeasureProcessTopTwo], a Process plugin measure, can ever know anything about what the value of [MeasureProcessTopOne] is. Substitute isn't a way to ask any question about any measure except the one it is on. Substitute, at its core, is always saying "take a look at the string value of THIS measure, and act on that."

You can use a Calc measure to evaluate the value(s) of both measures, and use IfCondition to drive the Text option (or FontColor, or whatever) on a String meter if you want. Just forget about the Substitute(s) on the two measures.

Code: Select all

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

[Variables]

[MeasureProcessTopOne]
Measure=Plugin
Plugin=Process
ProcessName=vlc.exe

[MeasureProcessTopTwo]
Measure=Plugin
Plugin=Process
ProcessName=qbittorrent.exe

[MeasureEval]
Measure=Calc
Formula=1
IfCondition=(MeasureProcessTopOne = 1) && (MeasureProcessTopTwo = -1)
IfTrueAction=[!SetOption MeterResult Text "vlc is running and qbittorrent isn't"][!UpdateMeter *][!Redraw]
IfCondition2=(MeasureProcessTopOne = -1) && (MeasureProcessTopTwo = -1)
IfTrueAction2=[!SetOption MeterResult Text "Neither is running"][!UpdateMeter *][!Redraw]
IfCondition3=(MeasureProcessTopOne = -1) && (MeasureProcessTopTwo = 1)
IfTrueAction3=[!SetOption MeterResult Text "qbittorrent is running and vlc isn't"][!UpdateMeter *][!Redraw]

[MeterResult]
Meter=String
FontSize=12
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Note that you don't absolutely need the separate Calc measure, as you can stick the IfCondition(s) directly on the [MeasureProcessTopTwo] measure if you want. I used the Calc measure mostly to make it clear that unlike Substitute/IfEqual/IfMatch, the IfCondition(s) are NOT about the measure they are on, but can easily reference and evaluate the values of multiple measures.
Something like this did come to mind. I couldn't get it right though. So thanks for the example, I certainly need it.

I just had a bug in my mind that the Substitute was possible. I know now that it is not the way.

Cheers.

(I will drop a line if I need more help :) )
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.