Sign in to follow this  
Followers 0
Scampy

Fan speed (open hardware monitor)

2 posts in this topic

#1 ·  Posted (edited)

Hi! How to display the CPU fan speed according to this example:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>

If not ProcessExists("OpenHardwareMonitor.exe") Then
Msgbox (16, "Error", "Please start OpenHardwareMonitor.exe")
Exit
EndIf
$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$strComputer = "."
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\OpenHardwareMonitor")

GUICreate ("CPU", 200,200)

GUICtrlCreateLabel ("Temperature", 10, 10, 100, 20)
GUICtrlCreateLabel ("Fan speed", 10, 40, 100, 20)

$CPUTemp = GUICtrlCreateLabel("", 130, 10, 50, 20)
$CPUFan = GUICtrlCreateLabel("", 130, 40, 50, 20)

GUISetState()

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch

$colItems = $objWMIService.ExecQuery("SELECT * FROM Sensor", "WQL",$wbemFlagReturnImmediately + $wbemFlagForwardOnly)
For $objItem in $colItems
if $objItem.SensorType = 'Temperature' and StringInStr($objItem.Parent, 'cpu') Then
If StringInStr($objItem.Name , "Package") Then
_GuiCtrlSetData($CPUTemp, $objItem.Value & " °C")
EndIf
EndIf
if $objItem.SensorType = 'Fan' and StringInStr($objItem.Parent, 'mainboard') Then
If StringInStr($objItem.Name , "Fan #1") Then
_GuiCtrlSetData($CPUFan, $objItem.Value & " RPM")
EndIf
EndIf
Next
WEnd

Func _GUICtrlSetData($iCtrlID, $sData)
If GUICtrlRead($iCtrlID, 1) <> $sData Then GUICtrlSetData($iCtrlID, $sData)
EndFunc ;==>_GUICtrlSetData

Sensor "Fan" does not work. Or I'm doing something wrong?

Edited by Scampy

Share this post


Link to post
Share on other sites



I found a solution. "Hardware" called "lpc"! But not "mainboard"! Bug?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0