It is currently December 4th, 2020, 1:53 am

Open Hardware Monitor plugin

Share and get help with Plugins and Addons
ouzbed
Posts: 16
Joined: December 2nd, 2014, 8:06 am

Open Hardware Monitor plugin

Post by ouzbed »

Hello,

I look for a way to communicate with Rainmeter Open Hardware Monitor.
OHM is a software I especially apreciated and Rainmeter . the concern is that it is difficult to retrieve information for OHM to inject them into Rainmeter . there is indeed a plugin which was released in 2011, but it is not very stable and uses WMI , which is quite slow and consumes a lot of resources.

I saw that one could query the OHM questioning the DLL ( OpenHardwareMonitorLib.dll ) that accompanies it as in the following example:

Code: Select all

namespace cs_TempReader
{
    class Program
    {
        private DateTime now;
        protected readonly ListSet<ISensor> active = new ListSet<ISensor>();
        public event SensorEventHandler SensorAdded;
        public event SensorEventHandler SensorRemoved;

        protected virtual void ActivateSensor(ISensor sensor)
        {
            if (active.Add(sensor))
                if (SensorAdded != null)
                    SensorAdded(sensor);
        }

        private static void Main(string[] args)
        {
            var myComputer = new Computer();

            myComputer.CPUEnabled = true;
            myComputer.ToCode();
            myComputer.Open();

            foreach (var hardwareItem in myComputer.Hardware)
            {
                hardwareItem.Update();
                hardwareItem.GetReport();

                Console.WriteLine(hardwareItem.GetReport());

                var series = new LineSeries();

                foreach (var sensor in hardwareItem.Sensors)
                {
                    if (sensor.SensorType == SensorType.Temperature)
                    {
                        Console.WriteLine("{0} {1} {2} = {3}", sensor.Name, sensor.Hardware, sensor.SensorType, sensor.Value);

                    }

                }
            }
        }
    }
}
do not like doing that, but my knowledge of C ++ are more than light ... is it possible for a C ++ guru to adapt this code for a Rainmeter plugin ?

thank you very much ! :welcome:
ouzbed
Posts: 16
Joined: December 2nd, 2014, 8:06 am

Re: Open Hardware Monitor plugin

Post by ouzbed »

making some progress...

this code works with admin rights in cmd :

Code: Select all

using System;
using OpenHardwareMonitor.Hardware;
namespace ConsoleApplication1
{
class Program
{
    static void Main(string[] args)
    {
        Computer thisComputer = new Computer();
        thisComputer.MainboardEnabled = true;
        thisComputer.CPUEnabled = true;
        thisComputer.Open();
        foreach(var hardware in thisComputer.Hardware)
        {
            foreach(var subhardware in hardware.SubHardware)
            {
                subhardware.Update();
                if(subhardware.Sensors.Length > 0)
                {
                    foreach(var sensor in subhardware.Sensors)
                    {
                        if(sensor.SensorType == SensorType.Fan && sensor.Name.Equals("Fan #1", StringComparison.OrdinalIgnoreCase))
                        {
                            Console.WriteLine((string) sensor.Name + ": " + Convert.ToString((int) (float) sensor.Value));
                        }
                        if(sensor.SensorType == SensorType.Fan && sensor.Name.Equals("Fan #2", StringComparison.OrdinalIgnoreCase))
                        {
                            Console.WriteLine((string) sensor.Name + ": " + Convert.ToString((int) (float) sensor.Value));
                        }
                        if (sensor.SensorType == SensorType.Fan && sensor.Name.Equals("Fan #3", StringComparison.OrdinalIgnoreCase))
                        {
                            Console.WriteLine((string)sensor.Name + ": " + Convert.ToString((int)(float)sensor.Value));
                        }
                    }
                }
            }
        }
    }
}
}
compiled in VS, it outputs an .exe which shows 3 first fans speed at each launch. it only needs OpenHardwareMonitorLib.dll to work, no need to OpenHardwareMonitor.exe running.

time to try to adapt it on Rainmeter plugin SDK ! because I'm more than a novice, see you in a month ! :D
username
Posts: 2
Joined: February 17th, 2016, 8:12 pm

Re: Open Hardware Monitor plugin

Post by username »

thanks man i am glad that you are doing this cuz i dont have any success at least i exepted more and many things are still not working... so when you could help me there it would be very appreciated :D :thumbup:
Andi_2112
Posts: 3
Joined: March 15th, 2016, 8:56 pm

Re: Open Hardware Monitor plugin

Post by Andi_2112 »

I made a plugin for OHM. You can download it here: https://drive.google.com/folderview?id=0B_LDiv0xMci2UlV1SGR0eG05c1U&usp=sharing

You need to copy the OHM Libary next to the rainmeter.exe and run rainmeter as admin

Measures:
gpuload, gputemp, cpuload, cputemp

Let me know if you need other hardware properties from OHM. :)
User avatar
~Faradey~
Posts: 367
Joined: November 12th, 2009, 4:47 pm
Location: Ukraine

Re: Open Hardware Monitor plugin

Post by ~Faradey~ »

Andi_2112 wrote:I made a plugin for OHM. You can download it here: https://drive.google.com/folderview?id=0B_LDiv0xMci2UlV1SGR0eG05c1U&usp=sharing

You need to copy the OHM Libary next to the rainmeter.exe and run rainmeter as admin

Measures:
gpuload, gputemp, cpuload, cputemp

Let me know if you need other hardware properties from OHM. :)
Could you give an example of how to use it, i'd like to test it but simply having a .dll is not enough. What syntax it has and ect.
Thanks ;)
Andi_2112
Posts: 3
Joined: March 15th, 2016, 8:56 pm

Re: Open Hardware Monitor plugin

Post by Andi_2112 »

~Faradey~ wrote:Could you give an example of how to use it, i'd like to test it but simply having a .dll is not enough. What syntax it has and ect.
Thanks ;)
Example for the current gpu temperature:

Code: Select all

[gpuTemp]
Measure=Plugin
Plugin=HardwareMonitor.dll
Type=gputemp

[GPUText]
Meter=STRING
MeasureName=gpuTemp
X=5
Y=5
other possible types:
  • gpuload (current gpu usage)
  • cpuload (current cpu usage)
  • cputemp (current cpu temperature)
Let me know, if you need further values from OHM. ;-)
User avatar
Brian
Developer
Posts: 2076
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: Open Hardware Monitor plugin

Post by Brian »

Andi_2112 wrote:You need to copy the OHM Libary next to the rainmeter.exe and run rainmeter as admin
This is really unfortunate and something I would NOT recommend to anyone for several reasons. We would really like to discourage people from manually having to install plugins (or in this case, 3rd party .dll's). Several years ago, there was a lot of malware aimed at getting people to run some sort of skin installation program that was just really malware.

To combat this, we want all users to install skins and plugins through a .rmskin package. This way we can put the correct files in the correct place without the bad guys trying to hi-jack our product.

Installing a 3rd party .dll to the Program Files Rainmeter folder, then requesting admin status for Rainmeter.exe can be dangerous IF there is malware. (Not saying there is).

-Brian

PS - I am not suggesting this plugin is malware, I am just suggesting this method of delivery is suspect and highly NOT recommended.
User avatar
jsmorley
Developer
Posts: 21518
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Open Hardware Monitor plugin

Post by jsmorley »

I concur with Brian, and in addition I'm not sure I like the entire concept of using a "bridge" .dll to have Rainmeter reach through and access another program's .dll files.
Andi_2112
Posts: 3
Joined: March 15th, 2016, 8:56 pm

Re: Open Hardware Monitor plugin

Post by Andi_2112 »

Brian wrote:Installing a 3rd party .dll to the Program Files Rainmeter folder, then requesting admin status for Rainmeter.exe can be dangerous IF there is malware. (Not saying there is).
It's now on Github (here) so you can compile it yourself if you don't trust me. ;-)
User avatar
Brian
Developer
Posts: 2076
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: Open Hardware Monitor plugin

Post by Brian »

Andi_2112 wrote:It's now on Github (here) so you can compile it yourself if you don't trust me. ;-)
Thanks for this information, however, this is still the wrong approach. The problem is NOT your plugin, it is requiring people to manually move (or copy) a .dll file and place it in the Rainmeter folder in order for your plugin to work. We really prefer people to install plugins through a .rmskin package and that cannot and will not ever support placing .dll files in the Rainmeter folder directly. Not to mention requiring Rainmeter to be ran as an admin (not that there is anything wrong with this, just an extra step that most users don't know how to do).

I applaud the effort, and I am glad there is someone tackling this plugin - however, this approach is a round-about way of using the OHM library and is not recommended. Plugins should be able to get the information on their own (without manually moving files around), or query other programs for information.

-Brian