It is currently May 18th, 2021, 11:30 pm

Monitoring multiple processes

Help with creating, editing & fixing problems with skins
Paasklaas
Posts: 2
Joined: April 18th, 2021, 5:50 pm

Monitoring multiple processes

Post by Paasklaas »

Hi,

Can anyone help me with the following.

I want to activate and deactivate certain skins when a certain process is started or stopped. I got this and this works:

[Variables]

Code: Select all

[MeasureProcesses-Pokerstars]
Measure=Plugin
Plugin=Process
ProcessName=Pokerstars.exe
IfAboveValue=0
IfAboveAction=[!ActivateConfig Rainmeter-Desktop\Backgrounds "Pokerstars.ini"][!ActivateConfig Rainmeter-Desktop\Docks\Vertical-Mode "Rainmeter-Vertical.ini"][!ActivateConfig Rainmeter-Desktop\Clocks\Vertical-Mode "clock_small.ini"][!DeactivateConfig Rainmeter-Desktop\Clocks\Horizontal-Mode clock_big.ini"][!DeactivateConfig Rainmeter-Desktop\Docks\Horizontal-Mode "Rainmeter-Horizontal.ini"][!ActivateConfig MonstercatVisualizer "visualizer.ini"]
IfBelowValue=1
IfBelowAction=[!ActivateConfig Rainmeter-Desktop\Backgrounds "Ice_Mountains.ini"][!ActivateConfig Rainmeter-Desktop\Docks\Horizontal-Mode "Rainmeter-Horizontal.ini"][!ActivateConfig Rainmeter-Desktop\Clocks\Horizontal-Mode "clock_big.ini][!DeactivateConfig Rainmeter-Desktop\Docks\Vertical-Mode "Rainmeter-Vertical.ini"][!DeactivateConfig Rainmeter-Desktop\Clocks\Vertical-Mode "clock_small.ini"][!DeactivateConfig MonstercatVisualizer "visualizer.ini"]
Now what I want is to monitor multiple processes and activate and deactivate skins based on the process that is running. You may assume that the processes will not overlap each other.

Is this possible?

Thank you in advance!

Regards,

Dennis
User avatar
balala
Rainmeter Sage
Posts: 12670
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Monitoring multiple processes

Post by balala »

Paasklaas wrote: April 18th, 2021, 5:56 pm Is this possible?
For sure it is, however what are you asking is not equivocal.
But here is an example. The following code checks for three processes: Notepad.exe, Paint.exe and Notepad++.exe. Since I don't have all those programs installed which have you used in your code, I had to work with these:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1

[MeasureNotepad]
Measure=Plugin
Plugin=Process
ProcessName=Notepad.exe

[MeasurePaint]
Measure=Plugin
Plugin=Process
ProcessName=Mspaint.exe

[MeasureNotepadP]
Measure=Plugin
Plugin=Process
ProcessName=Notepad++.exe

[MeasureNotepadPaintNotepadP]
Measure=Calc
Formula=( Clamp ( MeasureNotepad, 0, 1 ) + 10 * Clamp ( MeasurePaint, 0, 1 ) + 100 * Clamp ( MeasureNotepadP, 0, 1 ))
IfCondition=(Round(10*Frac(#CURRENTSECTION#/10))>=1)
IfTrueAction=[!ActivateConfig "NOTEPAD-IS-RUNNING" "Skin1.ini"]
IfFalseAction=[!DeactivateConfig "NOTEPAD-IS-RUNNING"]
IfCondition2=(10*Frac(#CURRENTSECTION#/100)>=1)
IfTrueAction2=[!ActivateConfig "PAINT-IS-RUNNING" "Skin2.ini"]
IfFalseAction2=[!DeactivateConfig "PAINT-IS-RUNNING"]
IfCondition3=(10*Frac(#CURRENTSECTION#/1000)>=1)
IfTrueAction3=[!ActivateConfig "NOTEPAD++-IS-RUNNING" "Skin3.ini"]
IfFalseAction3=[!DeactivateConfig "NOTEPAD++-IS-RUNNING"]
According to what the three measures ([MeasureNotepad], [MeasurePaint] and [MeasureNotepadP]) are returning, the [MeasureNotepadPaintNotepadP] measure calculates a value. The three IfConditions evalueate this value and act accordingly: if Notepad.exe is running, the Skin1.ini skin of the NOTEPAD-IS-RUNNING config is activated. If Notepad.exe is closed, the NOTEPAD-IS-RUNNING config is deactivated.
Same way, the IfConditions are activating / deactivating the skin of PAINT-IS-RUNNING and NOTEPAD++-IS-RUNNING configs as well.
Obviously you have to rewrite the IfTrueAction / IfFalseAction options, according to your needs.
If needed you can add further process measures.
Please let me know if you got this code working and doing what you need. Also let me know if you have to add further processes, but don't know how.
Paasklaas
Posts: 2
Joined: April 18th, 2021, 5:50 pm

Re: Monitoring multiple processes

Post by Paasklaas »

balala wrote: April 18th, 2021, 8:14 pm For sure it is, however what are you asking is not equivocal.
But here is an example. The following code checks for three processes: Notepad.exe, Paint.exe and Notepad++.exe. Since I don't have all those programs installed which have you used in your code, I had to work with these:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1

[MeasureNotepad]
Measure=Plugin
Plugin=Process
ProcessName=Notepad.exe

[MeasurePaint]
Measure=Plugin
Plugin=Process
ProcessName=Mspaint.exe

[MeasureNotepadP]
Measure=Plugin
Plugin=Process
ProcessName=Notepad++.exe

[MeasureNotepadPaintNotepadP]
Measure=Calc
Formula=( Clamp ( MeasureNotepad, 0, 1 ) + 10 * Clamp ( MeasurePaint, 0, 1 ) + 100 * Clamp ( MeasureNotepadP, 0, 1 ))
IfCondition=(Round(10*Frac(#CURRENTSECTION#/10))>=1)
IfTrueAction=[!ActivateConfig "NOTEPAD-IS-RUNNING" "Skin1.ini"]
IfFalseAction=[!DeactivateConfig "NOTEPAD-IS-RUNNING"]
IfCondition2=(10*Frac(#CURRENTSECTION#/100)>=1)
IfTrueAction2=[!ActivateConfig "PAINT-IS-RUNNING" "Skin2.ini"]
IfFalseAction2=[!DeactivateConfig "PAINT-IS-RUNNING"]
IfCondition3=(10*Frac(#CURRENTSECTION#/1000)>=1)
IfTrueAction3=[!ActivateConfig "NOTEPAD++-IS-RUNNING" "Skin3.ini"]
IfFalseAction3=[!DeactivateConfig "NOTEPAD++-IS-RUNNING"]
According to what the three measures ([MeasureNotepad], [MeasurePaint] and [MeasureNotepadP]) are returning, the [MeasureNotepadPaintNotepadP] measure calculates a value. The three IfConditions evalueate this value and act accordingly: if Notepad.exe is running, the Skin1.ini skin of the NOTEPAD-IS-RUNNING config is activated. If Notepad.exe is closed, the NOTEPAD-IS-RUNNING config is deactivated.
Same way, the IfConditions are activating / deactivating the skin of PAINT-IS-RUNNING and NOTEPAD++-IS-RUNNING configs as well.
Obviously you have to rewrite the IfTrueAction / IfFalseAction options, according to your needs.
If needed you can add further process measures.
Please let me know if you got this code working and doing what you need. Also let me know if you have to add further processes, but don't know how.
Wow thank you!!!

Now I first going to try and error. Most of it is clear. The 'clamp' statement and the formula are new to me, but the best way to learn is by trying. If I really can't figure it out I will come back to you.

Thanks again!!

Regards
Dennis
User avatar
balala
Rainmeter Sage
Posts: 12670
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Monitoring multiple processes

Post by balala »

Paasklaas wrote: April 22nd, 2021, 5:52 am Now I first going to try and error. Most of it is clear. The 'clamp' statement and the formula are new to me, but the best way to learn is by trying. If I really can't figure it out I will come back to you.
The created Formula is definitely something which on your request had to be created. When you had to activate / deactivate the skins based on the status of a single process, there was not needed, but when multiple processes had came in, the more complex calculation had to be added. That's why I added the formula. Hope you succeeded figuring out what's going on there.
But let's let you know about a little mistake you made in your initial code. I fixed it in my code, but maybe (supposably) you didn't even realized, so I'm explain it: the !DeactivateConfig bang, unlike !ActivateConfig, requires one less parameter: the name of the skin is not needed. Here is a concrete example on what am I talking about: in your initial code, you were using the mentioned !DeactivateConfig bang this way (posting one single example): [!DeactivateConfig Rainmeter-Desktop\Docks\Vertical-Mode "Rainmeter-Vertical.ini"]. The green colored parameter is correct, the red colored one is in vain: it's not needed. If you're using it, the bang works, it simply omits it, but correctly you have to not use it. The correct form of this bang is [!DeactivateConfig Rainmeter-Desktop\Docks\Vertical-Mode] (well, in fact, its really - really correct and complete form is [!DeactivateConfig "Rainmeter-Desktop\Docks\Vertical-Mode"] - with quotes). The quote is usually not needed, but if accidentally the name of the config contains space (which is not usually, but can happen) the quotes become essential. And even if in this case it's not the case, it's a good idea to get used to use it. So suggest you to use the !DeactivateConfig bang with one single parameter, the name of config. I used it this way, if you see my code.
So modify my code, replacing the !ActivateConfig and !DeactivateConfig bangs into the IfTrueAction and IfFalseAction options of my code with the appropriate bangs, try out the code and let me know how does it work. Hope it will and hope you'll succeeding modifying my code in a way to can get working the skin based on it, but if you encounter any problems, feel free anytime to come back with questions, asking for further help, in order to get the skin working as you expect it to work. Good luck...