It is currently April 23rd, 2024, 8:54 pm

OHM plugin and variables

Share and get help with Plugins and Addons
Itseotle
Posts: 3
Joined: August 6th, 2013, 1:53 pm

OHM plugin and variables

Post by Itseotle »

Hello all! I am sorry for making my first post a question but I really did try to solve the issue myself, and looked all over for answers.

What I am trying to do is make a simple CPU monitor using the Open Hardware Monitor plugin for Rainmeter, but instead of forcing a predefined name for the plugin to use I want to use the registry meter to find the hardware information. The problem is the OHM plugin doesn't allow variables or calling other measures in the use of its options. Is there a way around this?

I am still new and teaching myself the code so it might not be optimal :)

Code: Select all

[MeasureCPUname]
Measure=Registry
RegHKey=HKEY_LOCAL_MACHINE
RegKey=HARDWARE\DESCRIPTION\System\CentralProcessor\0
RegValue=ProcessorNameString
UpdateDivider=-1
RegExpSubstitute=1
Substitute="\(TM\)":"","\(R\)":"","CPU.*":""
;This will return a valid CPU name that OHM can use.

[MeasureCPUclock]
Measure=Plugin
Plugin=Plugins\OpenHardwareMonitorPlugin.dll
Hardware=[MeasureCPUname]
Type=Clocks
Sensor=CPU Core #1

[MeterCPUclock]
Meter=String
MeasureName=MeasureCPUclock
X=200
Y=100
W=500
H=25
FontColor=#FontColor#
Text="Clock: %1"
This code will cause rainmeter to flag an error at launch, reading "Requested sensor doesn't exist. Hardware: [MeasureCPUname]"
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: OHM plugin and variables

Post by jsmorley »

You can try setting DynamicVariables=1 on your [MeasureCPUclock] measure, but I have no idea if this plugin can use dynamic variables. If it doesn't, you might be stuck.
User avatar
moshi
Posts: 1740
Joined: November 13th, 2012, 9:53 pm

Re: OHM plugin and variables

Post by moshi »

as this value needs to be read only once, you could also add:

Code: Select all

[MeasureCalc1]
Measure=Time
DynamicVariables=1
OnChangeAction=[!WriteKeyValue "MeasureCPUclock" "Hardware" "[MeasureCPUname]" "#CURRENTFILE#"][!WriteKeyValue "MeasureCPUname" "Disabled" "1" "#CURRENTFILE#"][!WriteKeyValue "MeasureCalc1" "Disabled" "1" "#CURRENTFILE#"][!Refresh "#CURRENTCONFIG#"]
be careful when you plan to distribute that thing though. you'd need to reverse those changes made by the above measure.
Itseotle
Posts: 3
Joined: August 6th, 2013, 1:53 pm

Re: OHM plugin and variables

Post by Itseotle »

jsmorley wrote:You can try setting DynamicVariables=1 on your [MeasureCPUclock] measure, but I have no idea if this plugin can use dynamic variables. If it doesn't, you might be stuck.
Yes I have tried that, I just forgot to include that in my original post. That sadly doesn't work.
moshi wrote:as this value needs to be read only once, you could also add:

Code: Select all

[MeasureCalc1]
Measure=Time
DynamicVariables=1
OnChangeAction=[!WriteKeyValue "MeasureCPUclock" "Hardware" "[MeasureCPUname]" "#CURRENTFILE#"][!WriteKeyValue "MeasureCPUname" "Disabled" "1" "#CURRENTFILE#"][!WriteKeyValue "MeasureCalc1" "Disabled" "1" "#CURRENTFILE#"][!Refresh "#CURRENTCONFIG#"]
be careful when you plan to distribute that thing though. you'd need to reverse those changes made by the above measure.
Hmm I'll give that a try. I am assuming what this snippet does is replace the value directly within the .ini file my meter runs off? I didn't know rainmeter had those kinds of abilities. Good to know thanks! Could this be used to alter predefined variables as well? That would probably be a more streamlined solution, as the OHM plugin will read static variables. Hardware=#Variable# will work, for example.

EDIT: Thanks that worked better than I thought, and no errors are thrown even at first launch. I figured out on my own you can use this for variables and I am going to guess just about any snippet in rainmeter. I also see the power of the Disabled=1 function in helping to manage separate modules within a meter, so thanks for those tips! :)