Chimaera Posted March 22, 2013 Share Posted March 22, 2013 I was having a look at the CPU Temp script by chris L Func _ACPI_Temp() Local $wbemFlagReturnImmediately = 0x10, $strComputer, $objWMIService, $colItems Local $wbemFlagForwardOnly = 0x20 Local $CurrTemp = "N/A" $strComputer = "." $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\wmi") $colItems = $objWMIService.ExecQuery("SELECT * FROM MSAcpi_ThermalZoneTemperature", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) For $objItem In $colItems $CurrTemp = ($objItem.CurrentTemperature - 2732) / 10 Next Return $CurrTemp EndFunc ;==>_ACPI_Temp And it gives me the temp as expected, the thing i dont know is how to get it to refresh the temp every 30 secs? Any suggestions? Could i use ContinueLoop here For $objItem In $colItems $CurrTemp = ($objItem.CurrentTemperature - 2732) / 10 Next but how do i get it to understand every 30 secs? If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
FireFox Posted March 22, 2013 Share Posted March 22, 2013 What about executing the query every 30 seconds ? Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted March 22, 2013 Moderators Share Posted March 22, 2013 I agree with FireFox, I would just set a HotKey to call the query every 30 seconds. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Chimaera Posted March 22, 2013 Author Share Posted March 22, 2013 (edited) Its on a Gui where it just shows the temp as a number but i want it to fluctuate as the temps rise and fall. Its only an indication so if we see high temps we investigate so automated is better as we are not always at the machine and we can pass by and just check Edited March 22, 2013 by Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
FireFox Posted March 22, 2013 Share Posted March 22, 2013 (edited) huh? Local Const $wbemFlagReturnImmediately = 0x10, $wbemFlagForwardOnly = 0x20 Local Const $strComputer = "." Local Const $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\wmi") While 1 ConsoleWrite(_ACPI_Temp() & @CrLf) Sleep(30000) WEnd Func _ACPI_Temp() Local $CurrTemp = "N/A" Local Const $colItems = $objWMIService.ExecQuery("SELECT * FROM MSAcpi_ThermalZoneTemperature", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) For $objItem In $colItems $CurrTemp = ($objItem.CurrentTemperature - 2732) / 10 Next Return $CurrTemp EndFunc ;==>_ACPI_Temp For your case it would be better to set a timer on your GUI instead of this sleep. Br, FireFox. Edited March 22, 2013 by FireFox Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted March 22, 2013 Moderators Share Posted March 22, 2013 FireFox beat me to it, but I was thinking of separating the two, in case you want to change only the temp function later. Something like this: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $temp AdlibRegister("_tempchange", 10000) Local $msg GUICreate("My CPU Temp GUI", 300, 300) $temp = GUICtrlCreateLabel("", 10, 10, 100, 40) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd GUIDelete() Func _tempchange() Local $wbemFlagReturnImmediately = 0x10, $strComputer, $objWMIService, $colItems Local $wbemFlagForwardOnly = 0x20 Local $CurrTemp = "N/A" $strComputer = "." $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\wmi") $colItems = $objWMIService.ExecQuery("SELECT * FROM MSAcpi_ThermalZoneTemperature", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) For $objItem In $colItems $CurrTemp = ($objItem.CurrentTemperature - 2732) / 10 Next GUICtrlSetData($temp, $CurrTemp) EndFunc FireFox 1 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Chimaera Posted March 22, 2013 Author Share Posted March 22, 2013 Thx ill have a play around. I didn't realise doing a ConsolWrite in that way would refresh an item If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
Emiel Wieldraaijer Posted March 23, 2013 Share Posted March 23, 2013 Hi,I tried the MSAcpi_ThermalZoneTemperature but it does not retrieve the correct temperature from the CPUhttp://openhardwaremonitor.org/files/openhardwaremonitor-v0.5.1-beta.zipOpen hardware monitor does, i must be possible to retrieve the temperature through a dll. I don't know how.. in the supplied example openhardwaremonitor.exe must be resident .expandcollapse popup#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 ("Load", 10, 40, 100,20) GUICtrlCreateLabel ("Power", 10, 70, 100,20) $CPUTemp = GUICtrlCreateLabel("", 130, 10, 50, 20, $SS_RIGHT) $CPULoad = GUICtrlCreateLabel("", 130, 40, 50, 20, $SS_RIGHT) $CPUPower = GUICtrlCreateLabel("", 130, 70, 50, 20, $SS_RIGHT) GUISetState() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch $colItems = $objWMIService.ExecQuery("SELECT * FROM Sensor", "WQL",$wbemFlagReturnImmediately + $wbemFlagForwardOnly) $Output="" $Power="" $Load="" For $objItem in $colItems if $objItem.SensorType = 'Power' and StringInStr($objItem.Parent, 'cpu') Then If StringInStr($objItem.Name , "Package") Then _GuiCtrlSetData($CPUPower, Round($objItem.Value,1) & " W") EndIf EndIf 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 = 'Load' and StringInStr($objItem.Parent, 'cpu') Then If StringInStr($objItem.Name , "Total") Then _GuiCtrlSetData($CPULoad, Round($objItem.Value,1) & " %") EndIf EndIf Next WEnd Func _GUICtrlSetData($iCtrlID, $sData) If GUICtrlRead($iCtrlID, 1) <> $sData Then GUICtrlSetData($iCtrlID, $sData) EndFunc ;==>_GUICtrlSetData Best regards,Emiel Wieldraaijer Link to comment Share on other sites More sharing options...
Chimaera Posted March 23, 2013 Author Share Posted March 23, 2013 Thx Emiel But im just looking for a basic indication, We use Aida if i really need to know whats going on I dont really want to add another program into the mix. Its a shame like you say that it cant be accessed from a dll etc. If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
Chimaera Posted April 2, 2013 Author Share Posted April 2, 2013 Think im going to have to revist this as ive found a flaw because its polling the consolewrite every 20 secs it stops the other buttons working in the gui Lol ill have to look at the other suggestions and see what else can be done If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
FireFox Posted April 2, 2013 Share Posted April 2, 2013 Which script are you using ? Link to comment Share on other sites More sharing options...
Chimaera Posted April 2, 2013 Author Share Posted April 2, 2013 This setup Func _ACPI_Temp() Local $wbemFlagReturnImmediately = 0x10, $strComputer, $objWMIService, $colItems Local $wbemFlagForwardOnly = 0x20 Local $CurrTemp = "N/A" $strComputer = "." $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\wmi") $colItems = $objWMIService.ExecQuery("SELECT * FROM MSAcpi_ThermalZoneTemperature", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) For $objItem In $colItems $CurrTemp = ($objItem.CurrentTemperature - 2732) / 10 ;$Critical = ($objItem.CriticalTripPoint - 2732) / 10 Next Return $CurrTemp EndFunc ;==>_ACPI_Temp and this in the while /wend ConsoleWrite(_ACPI_Temp() & @CrLf) ; Refreshes CPU Temp Funtion Sleep(20000) ; Every 20 Secs If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
FireFox Posted April 2, 2013 Share Posted April 2, 2013 Are you going to tell me that you don't know the existence of these functions : TimerInit/Diff, AdlibRegister, _WinAPI_SetTimer/_Timer_Init ? Link to comment Share on other sites More sharing options...
Chimaera Posted April 2, 2013 Author Share Posted April 2, 2013 (edited) Yep i have no idea as i never use anything like that I only write simple install programs and a bit of robocopy CMD stuff, im not a programmer I never deal with stuff like this till now Ill have a play with the examples and see what i can get working Edited April 2, 2013 by Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
FireFox Posted April 2, 2013 Share Posted April 2, 2013 Sorry if I seemed hard, I wanted to point out that it's not difficult. If you need any help, you know what to do Br, FireFox. Link to comment Share on other sites More sharing options...
Chimaera Posted April 2, 2013 Author Share Posted April 2, 2013 Its fine m8, im a hobbyist and i prob only use 1% of whats capable in AutoIt If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now