Recently Browsing 0 members
No registered users viewing this page.
Below is a function w/ a working example showing how to access the AIDA64 shared memory.
First enable shared memory here: Preferences > Hardware Monitoring > External Applications > Enable Shared Memory
The length of the data depends on the number of active sensors and their content. As AIDA64 does not provide a buffer size value, we use _WinAPI_GetSystemInfo() <WinAPISys.au3> to get dwPageSize ($aArray). This value is the used as an address offset, and we continue reading chunks of data until we encounter a 0x00 NUL character.
Based on the Delphi example found in the AIDA64 documentation: https://www.aida64.co.uk/user-manual/external-applications
Feedback appreciated, especially as all this shared memory stuff is not my ordinary cup of... cake. And regarding this whole ordeal of reading data without knowing the exact length; I'm suspecting my solution to read chunks of data like done below is not by the book, and I'm concerned what might happen if the final chunk is exactly 4096 bytes in length. Will there still be a NUL terminator there? Hmm.
#NoTrayIcon #include <WinAPIFiles.au3> #include <WinAPISys.au3> ; #INDEX# =========================================================================================================================== ; Title .........: AIDA64 Shared Memory access for AutoIt3 ; Author(s) .....: demux4555 ; Reference .....: https://www.aida64.co.uk/user-manual/external-applications ; =================================================================================================================================== Global $vSharedmem_data ; The variable used to store the data we read from the shared memory Global $return = ExtApp_SharedMem_ReadBuffer_v2($vSharedmem_data) ; Now, let's see what happens when we run the function... If @error Then _Echo("! ExtApp_SharedMem_ReadBuffer_v2(): @errror = " & @error) If IsBinary($vSharedmem_data) Then ; Convert type Binary to actual human readable text. We also remove the excess of trailing 0x00 characters. $vSharedmem_data = StringStripWS(BinaryToString($vSharedmem_data), $STR_STRIPLEADING+$STR_STRIPTRAILING) EndIf _Echo() _Echo("> return = " & $return) ; The return value. Will be True if everything went ok. _Echo("> length = " & StringLen($vSharedmem_data)) ; The number of characters read from shared memory. _Echo("> data = " & $vSharedmem_data) ; The actual data. _Echo("> data(40) = " & "..." & StringRight($vSharedmem_data, 40)) ; shows the 40 right-most characters, and _should_ show the very end of the data at this point. _Echo() Exit ; #FUNCTION# ==================================================================================================================== ; Name ..........: ExtApp_SharedMem_ReadBuffer_v2 ; Description ...: AIDA64 Shared Memory Example for AutoIt3 ; Syntax ........: ExtApp_SharedMem_ReadBuffer_v2(Byref $_dOutput[, $_sSharedmemName = "AIDA64_SensorValues"]) ; Parameters ....: $_dOutput - [in/out] Variable to store the read data. ; $_sSharedmemName - [optional] Name of the AIDA64 shared memory. Default is "AIDA64_SensorValues". ; Return values .: Success: True. $_dOutput will be type Binary, containing a string of the XML values of the active sensors. ; Failure: False. ; Author ........: demux4555 ; Reference .....: https://www.aida64.co.uk/user-manual/external-applications ; =============================================================================================================================== Func ExtApp_SharedMem_ReadBuffer_v2(ByRef $_dOutput, $_sSharedmemName = "AIDA64_SensorValues") Local $_bReturn = False Local $_aGSI = _WinAPI_GetSystemInfo() ; Retrieves information about the current system... Ref: https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getsysteminfo Local $_iPageSize = $_aGSI ; ... the page size and the granularity of page protection and commitment. Usually it is 4096, but we read it anyway. Ref: https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/ns-sysinfoapi-system_info Local $_hMapping = _WinAPI_OpenFileMapping($_sSharedmemName, $FILE_MAP_READ) ; Opens a named file mapping object. Ref: https://docs.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-openfilemappingw If Not IsPtr($_hMapping) Then Return SetError(-2, 0, $_bReturn) Local $_pMappedData = _WinAPI_MapViewOfFile($_hMapping, 0, 0, $FILE_MAP_READ) ; Pointer to the start address. Maps a view of a file mapping into the address space of a calling process. Ref: https://docs.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-mapviewoffile If @error Or Not IsPtr($_pMappedData) Then Return SetError(-2, 0, $_bReturn) ; Now we loop until we reach the end of the data. Local $_tData, $_dBuffer While 1 $_tData = DllStructCreate("BYTE[" & $_iPageSize & "]", $_pMappedData) ; Note: we use type BYTE (AutoIt type Binary) instead of CHAR (AutoIt type String). This allows us to look for value 0x00 (NUL termination of the data). If @error Then ExitLoop $_dBuffer = DllStructGetData($_tData, 1) ; The returned value is type Binary. If @error Or ($_dBuffer==0) Or (BinaryLen($_dBuffer)=0) Then ExitLoop ; Pretty sure $_dBuffer==0 can not happen, so just in case. $_dOutput = Binary($_dOutput & $_dBuffer) ; Add the read data to the end of the output variable. If StringRight($_dBuffer, 2)=="00" Then ExitLoop ; Look for NUL termination of the string data. $_pMappedData += $_iPageSize ; We change the address by using the page granularity value (i.e. 4096) as the offset. WEnd ; Quick cleanup $_bReturn = _WinAPI_UnmapViewOfFile($_pMappedData)=1 ; Unmaps a mapped view of a file from the calling process's address space. Ref: https://docs.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-unmapviewoffile _WinAPI_CloseHandle($_hMapping) Return $_bReturn EndFunc; Func _Echo($_data = "") ConsoleWrite($_data & @CRLF) EndFunc
The back story:
I've got a Dell XPS w/ i7-8700K. The fastest, by single core, I could get, by well known PC maker.
The problem is that the fan can get so loud, like, REALLY LOUD, I can not use the CPU at its max. clock speed.
I could leave it at 90% all the time and not use this but I want to have the full 4.x Ghz and no parked cores, at all times, if I can.
But as room temperature and CPU load changes, a set throttle, may still make fan noise.
To avoid the fan from going "airplane turbine mode", the utility gets the temp. from "Core Temp" ( you can google it )
It has a"plug-in" called "Core Temp Remote Server". The utility gets the values via TCP.
When it "feels" it's gonna get hot, drops the CPU throttle to a selected value, lets say 99% ( where is quieter ) and back up to 100% when it "feels" is ok to go back.
Now temperature can creep up to higher than expected if load is sustained or room temperature changes. So there is an "anti creep up" feature, to temporarily set the throttle even lower, 5% at a time, until the known quiet temperature is achieved.
If don't know how to find the temperature you should use, check out these videos. They will tell you how.
The end result:
Any thermal problem, is a hardware problem. No way around that, other than attending to the CPU cooling and case ventilation. Software can not fix that.
But without this utility, the PC would slow down the CPU anyway, to keep it from melting.
This software preemptively slow down the CPU, keeping the CPU related fan speeds from going to maximum RPM. Hence having a slower, but a quieter box.
Hello, I'm very stumped with finding the decimal place for the CPU %.
I found some example code online
#include <Array.au3> $aProcess_Info = GetCPU("RzSynapse") _ArrayDisplay($aProcess_Info) Func GetCPU($sProcess = "") Local $aAllProcess_Info = [], $aOneProcess_Info $oWinMgmts = ObjGet("winmgmts:\\.\root\cimv2") $aCPU_Usage = $oWinMgmts.ExecQuery("SELECT Name, IDProcess, PercentProcessorTime FROM Win32_PerfFormattedData_PerfProc_Process") For $vCPU_Info In $aCPU_Usage If $sProcess Then If $vCPU_Info.Name = $sProcess Then $aOneProcess_Info = $sProcess $aOneProcess_Info = $vCPU_Info.IDProcess $aOneProcess_Info = $vCPU_Info.PercentProcessorTime & " %" Return $aOneProcess_Info EndIf Else $aAllProcess_Info += 1 $aAllProcess_Info[$aAllProcess_Info] = $vCPU_Info.Name $aAllProcess_Info[$aAllProcess_Info] = $vCPU_Info.IDProcess $aAllProcess_Info[$aAllProcess_Info] = $vCPU_Info.PercentProcessorTime & " %.1f" EndIf Next ReDim $aAllProcess_Info[$aAllProcess_Info +1] Return $aAllProcess_Info EndFunc ;==>GetCPU Currently the code shows the CPU % as 0 % and I want to show 0.0 % I found this online for strings "%.1f" but i'm not sure how to incorporate it.
The simple widget shows the percentage of cpu, ram used and the CPU temperature (WMI).
- Every 30s check, sync and update time for computer.
- Drag adn Drop any files on GUI for reset Attribute (-RAHS) and set Full Access to Everyone !
- Righ Click on x and click Un/Install app to boot with Windows!
CPU_Widget_TimeSync.exe CRC32: 1956339E MD5: BFC2B596BD1EDA35D6B02B97F8FB57AE SHA-1: 796A663739EA5AC9890D9FA324A98E987F35E7C8
Function code from:
RAM: MemGetStats ( )
Memory: _WinAPI_EmptyWorkingSet ()
What am I supposed to do, if a program is able for a long time?
My program is idle for 20 minutes, before doing a very tiny task, and then starting all over again.
I tries using Sleep(), but that literally melts my CPU and pushes them up for 20 to 30%. Permanently checking the time costs too much CPU too.
Any other way of doing this? Preferably without taking more than 1% CPU. It also needn't be exactly 20 minutes, everything between 15 and 25 is fine too