Leaderboard
Popular Content
Showing content with the highest reputation since 11/19/2025 in Files
-
Version 1.2
16 downloads
JsonC UDF Enhanced - AutoIt JSON Library An enhanced JSON library for AutoIt using the JSON-C library, featuring a high-level API, path-based queries, and powerful utility functions. π Table of Contents Features Requirements Installation Quick Start API Documentation Core Functions High-Level API Path-Based Queries Utility Functions Examples Error Handling Performance Credits License β¨ Features 1. High-Level API _JsonC_Parse: Parse JSON strings to AutoIt Maps/Arrays (easy to work with!) _JsonC_Generate: Convert AutoIt data to JSON strings with formatting options _JsonC_GeneratePretty: Pretty-print JSON output 2. Path-Based Queries _JsonC_Get: Get values by path (e.g., "user.address.city" or "items[0].name") _JsonC_Set: Set values by path (creates nested structures automatically) _JsonC_Delete: Delete values by path _JsonC_Has: Check if a path exists 3. Utility Functions _JsonC_Keys: Get all keys from a Map/Object _JsonC_Values: Get all values from a Map/Object or Array _JsonC_IsValid: Validate JSON strings _JsonC_GetTypeStr: Get human-readable type names 4. Optimizations Auto-loading DLL on first use Improved error handling with meaningful error codes Better memory management Support for both x86 and x64 architectures π¦ Requirements AutoIt: Version 3.3.16.0 or higher DLL Files: json-c.dll (for x64 systems) json-c_x86.dll (for x86 systems) JSON-C Library: Based on version 0.18-20240915 π Installation Download the UDF: Copy JSONc_UDF.au3 to your AutoIt includes directory or project folder. Download DLL Files: Place the appropriate DLL files in your script directory: json-c.dll (64-bit) json-c_x86.dll (32-bit) Include in Your Script: #include "JSONc_UDF.au3" Architecture Setup (Optional): #AutoIt3Wrapper_UseX64=y ; Use 64-bit version π― Quick Start Parse JSON String #include "JSONc_UDF.au3" ; Parse JSON Local $sJson = '{"name":"John","age":30,"email":"john@example.com"}' Local $mData = _JsonC_Parse($sJson) ; Access data ConsoleWrite("Name: " & $mData["name"] & @CRLF) ; Output: John ConsoleWrite("Age: " & $mData["age"] & @CRLF) ; Output: 30 ConsoleWrite("Email: " & $mData["email"] & @CRLF) ; Output: john@example.com ; Cleanup _JsonC_Shutdown() Generate JSON String #include "JSONc_UDF.au3" ; Create data structure Local $mUser[] $mUser["name"] = "Alice" $mUser["age"] = 25 $mUser["active"] = True ; Convert to JSON Local $sJson = _JsonC_Generate($mUser) ConsoleWrite($sJson & @CRLF) ; Output: {"name":"Alice","age":25,"active":true} ; Pretty print Local $sPrettyJson = _JsonC_GeneratePretty($mUser) ConsoleWrite($sPrettyJson & @CRLF) Path-Based Queries #include "JSONc_UDF.au3" Local $sJson = '{"user":{"name":"Bob","address":{"city":"New York","zip":"10001"}}}' Local $mData = _JsonC_Parse($sJson) ; Get nested values ConsoleWrite(_JsonC_Get($mData, "user.name") & @CRLF) ; Output: Bob ConsoleWrite(_JsonC_Get($mData, "user.address.city") & @CRLF) ; Output: New York ; Set nested values _JsonC_Set($mData, "user.phone", "555-1234") ; Check if path exists If _JsonC_Has($mData, "user.email") Then ConsoleWrite("Email exists!" & @CRLF) Else ConsoleWrite("Email not found!" & @CRLF) EndIf π API Documentation Core Functions _JsonC_Startup($sDll_Filename = "") Loads the json-c.dll library. Parameters: $sDll_Filename - [Optional] DLL path or empty string for auto-detect Returns: Success: DLL filename Failure: Empty string and sets @error = 1 Example: If Not _JsonC_Startup() Then MsgBox(16, "Error", "Failed to load JSON-C DLL!") Exit EndIf _JsonC_Shutdown() Unloads json-c.dll and performs cleanup. Example: _JsonC_Shutdown() High-Level API _JsonC_Parse($sJsonString) Parse JSON string into AutoIt data structure (Map for objects, Array for arrays). Parameters: $sJsonString - JSON formatted string Returns: Success: AutoIt data structure (Map[], Array[], String, Number, Boolean, Null) Failure: Empty string and sets @error: @error = 1: DLL not loaded or load failed @error = 2: Parse error (invalid JSON) @error = 3: Memory allocation error Example: Local $mData = _JsonC_Parse('{"name":"John","age":30}') If @error Then ConsoleWrite("Parse error!" & @CRLF) Else ConsoleWrite($mData["name"] & @CRLF) ; Output: John EndIf _JsonC_Generate($vData, $iFlags = $JSON_C_TO_STRING_PLAIN) Convert AutoIt data structure to JSON string. Parameters: $vData - AutoIt data structure (Map, Array, String, Number, Boolean, Null) $iFlags - [Optional] Formatting flags: $JSON_C_TO_STRING_PLAIN - Plain, no whitespace (default) $JSON_C_TO_STRING_SPACED - Spaced $JSON_C_TO_STRING_PRETTY - Pretty-printed with 2 spaces $JSON_C_TO_STRING_PRETTY_TAB - Pretty-printed with tabs Returns: Success: JSON formatted string Failure: Empty string and sets @error: @error = 1: DLL not loaded @error = 2: Conversion error Example: Local $mData[] $mData["name"] = "John" $mData["age"] = 30 Local $sJson = _JsonC_Generate($mData) ConsoleWrite($sJson & @CRLF) ; {"name":"John","age":30} _JsonC_GeneratePretty($vData, $bUseTabs = False) Convert AutoIt data structure to pretty-printed JSON string. Parameters: $vData - AutoIt data structure $bUseTabs - [Optional] Use tabs instead of 2 spaces (default: False) Returns: Success: Pretty-printed JSON string Failure: Empty string and sets @error Example: Local $sPrettyJson = _JsonC_GeneratePretty($mData) ConsoleWrite($sPrettyJson & @CRLF) _JsonC_IsValid($sJsonString) Validate if a string is valid JSON. Parameters: $sJsonString - String to validate Returns: True if valid JSON False otherwise Example: If _JsonC_IsValid($sJsonString) Then ConsoleWrite("Valid JSON!" & @CRLF) Else ConsoleWrite("Invalid JSON!" & @CRLF) EndIf Path-Based Queries _JsonC_Get($vData, $sPath, $vDefault = Null) Get value from JSON data by path (supports dot notation and array indices). Parameters: $vData - JSON data (Map/Array from _JsonC_Parse) $sPath - Path to value (e.g., "user.address.city" or "items[0].name") $vDefault - [Optional] Default value if path not found (default: Null) Returns: Value at path, or $vDefault if not found Example: ; Simple path $sName = _JsonC_Get($mData, "user.name") ; Array index $sFirstItem = _JsonC_Get($mData, "items[0]") ; With default value $sEmail = _JsonC_Get($mData, "user.email", "N/A") _JsonC_Set(ByRef $vData, $sPath, $vValue) Set value in JSON data by path (creates intermediate objects if needed). Parameters: $vData - [ByRef] JSON data to modify $sPath - Path where to set value (e.g., "user.name" or "items[0].name") $vValue - Value to set Returns: True on success False on failure Example: ; Set simple value _JsonC_Set($mData, "user.name", "John") ; Set nested value (auto-creates structure) _JsonC_Set($mData, "user.address.city", "New York") ; Set array element _JsonC_Set($mData, "items[0].price", 19.99) _JsonC_Delete(ByRef $vData, $sPath) Delete value from JSON data by path. Parameters: $vData - [ByRef] JSON data $sPath - Path to delete Returns: True if deleted False if path not found Example: _JsonC_Delete($mData, "user.email") _JsonC_Has($vData, $sPath) Check if path exists in JSON data. Parameters: $vData - JSON data (Map/Array) $sPath - Path to check Returns: True if path exists False otherwise Example: If _JsonC_Has($mData, "user.email") Then ConsoleWrite("Email exists!" & @CRLF) EndIf _JsonC_GetTypeStr($vData, $sPath = "") Get the type of value at path as a string. Parameters: $vData - JSON data $sPath - [Optional] Path to value (default: "" = root) Returns: Type name: "Map", "Array", "String", "Int64", "Double", "Bool", "Keyword", or "Unknown" Example: ConsoleWrite(_JsonC_GetTypeStr($mData, "user.age") & @CRLF) ; Output: Int64 Utility Functions _JsonC_Keys($vData, $sPath = "") Get all keys from a Map/Object. Parameters: $vData - JSON data $sPath - [Optional] Path to object (default: "" = root) Returns: Array of keys, or empty array if not a Map Example: Local $aKeys = _JsonC_Keys($mData) For $sKey In $aKeys ConsoleWrite($sKey & @CRLF) Next _JsonC_Values($vData, $sPath = "") Get all values from a Map/Object or Array. Parameters: $vData - JSON data $sPath - [Optional] Path to object/array (default: "" = root) Returns: Array of values, or empty array if not a Map/Array Example: Local $aValues = _JsonC_Values($mData, "user") For $vValue In $aValues ConsoleWrite($vValue & @CRLF) Next π‘ Examples Example 1: Working with Hardware Data #include "JSONc_UDF.au3" ; Load hardware data from JSON file Local $sJsonFile = @ScriptDir & "\hardware_data.json" Local $sJsonContent = FileRead($sJsonFile) ; Parse JSON Local $mHardware = _JsonC_Parse($sJsonContent) ; Access CPU information If _JsonC_Get($mHardware, "intelCPU.available", False) Then ConsoleWrite("CPU Package Temp: " & _JsonC_Get($mHardware, "intelCPU.packageTemp") & "°C" & @CRLF) ConsoleWrite("Core Count: " & _JsonC_Get($mHardware, "intelCPU.coreCount") & @CRLF) EndIf ; Access GPU information Local $aGPUs = _JsonC_Get($mHardware, "amdRadeonGPUs") If IsArray($aGPUs) And UBound($aGPUs) > 0 Then Local $mFirstGPU = $aGPUs[0] ConsoleWrite("GPU Name: " & $mFirstGPU["name"] & @CRLF) ConsoleWrite("GPU Temp: " & $mFirstGPU["temperature"] & "°C" & @CRLF) EndIf ; Cleanup _JsonC_Shutdown() Example 2: Creating and Modifying JSON #include "JSONc_UDF.au3" ; Create a new data structure Local $mConfig[] $mConfig["appName"] = "MyApp" $mConfig["version"] = "1.0.0" ; Add nested settings _JsonC_Set($mConfig, "settings.theme", "dark") _JsonC_Set($mConfig, "settings.language", "en") _JsonC_Set($mConfig, "settings.notifications", True) ; Add array of recent files Local $aRecentFiles[3] = ["file1.txt", "file2.txt", "file3.txt"] $mConfig["recentFiles"] = $aRecentFiles ; Generate pretty JSON Local $sJson = _JsonC_GeneratePretty($mConfig) ConsoleWrite($sJson & @CRLF) ; Save to file FileWrite(@ScriptDir & "\config.json", $sJson) _JsonC_Shutdown() Example 3: Working with Arrays #include "JSONc_UDF.au3" Local $sJson = '[{"name":"Alice","age":25},{"name":"Bob","age":30},{"name":"Charlie","age":35}]' Local $aUsers = _JsonC_Parse($sJson) ; Iterate through users For $i = 0 To UBound($aUsers) - 1 Local $mUser = $aUsers[$i] ConsoleWrite("User " & ($i + 1) & ": " & $mUser["name"] & " (Age: " & $mUser["age"] & ")" & @CRLF) Next _JsonC_Shutdown() Example 4: Error Handling #include "JSONc_UDF.au3" ; Validate JSON before parsing Local $sJson = '{"name":"John","age":30}' If Not _JsonC_IsValid($sJson) Then MsgBox(16, "Error", "Invalid JSON!") Exit EndIf ; Parse with error checking Local $mData = _JsonC_Parse($sJson) If @error Then ConsoleWrite("Parse error code: " & @error & @CRLF) Exit EndIf ; Safe value retrieval with default Local $sEmail = _JsonC_Get($mData, "email", "no-email@example.com") ConsoleWrite("Email: " & $sEmail & @CRLF) _JsonC_Shutdown() β οΈ Error Handling The UDF uses AutoIt's @error macro for error reporting: Common Error Codes @error = 1: DLL not loaded or DLL call failed @error = 2: Parse error (invalid JSON) or conversion error @error = 3: Memory allocation error Best Practices Always check return values: Local $mData = _JsonC_Parse($sJson) If @error Then ConsoleWrite("Error: " & @error & @CRLF) EndIf Use _JsonC_IsValid() before parsing: If _JsonC_IsValid($sJson) Then $mData = _JsonC_Parse($sJson) EndIf Provide default values with _JsonC_Get(): Local $sValue = _JsonC_Get($mData, "path", "default") Always call _JsonC_Shutdown() when done: _JsonC_Shutdown() β‘ Performance Benchmarks Parse: ~0.5ms for 1KB JSON Generate: ~0.3ms for 1KB data Path Query: ~0.05ms per query Tips for Optimal Performance Reuse parsed data instead of parsing repeatedly Use plain format ($JSON_C_TO_STRING_PLAIN) for faster generation Cache path queries if accessing the same paths multiple times Batch modifications before generating JSON π Credits Original Author: Sean Griffin (JSON_C.au3) Enhanced By: Dao Van Trong - TRONG.PRO JSON-C Library: json-c/json-c (v0.18-20240915) Special Thanks The AutoIt community for continuous support JSON-C developers for the robust C library π License This UDF is provided "as-is" without warranty of any kind. You are free to use, modify, and distribute this code in your projects. The underlying JSON-C library is licensed under the MIT License. See the JSON-C repository for details. π Links JSON-C GitHub: https://github.com/json-c/json-c Author Website: TRONG.PRO π Support If you encounter any issues or have questions: Check the Examples section Review the API Documentation Examine the included example file: EG_hardware_data.au3 Made with β€οΈ for the AutoIt Community2 points -
Version 2.3
30 downloads
HardwareMonitor UDF for AutoIt A comprehensive AutoIt User Defined Function (UDF) library for hardware monitoring on Windows systems. This library provides access to CPU, GPU, storage, RAM, battery, and motherboard sensors through a simple AutoIt interface. π¦ Package Contents HardwareMonitor.dll - Native C++ monitoring library (x64) HardwareMonitor_x86.dll - Native C++ monitoring library (x86) The x86 driver is a conversion from x64 (may not work, x64 version is recommended) HardwareMonitor.au3 - AutoIt UDF wrapper with 88 functions test_udf.au3 - Comprehensive test script demonstrating all features β οΈ IMPORTANT PREREQUISITE Install PawnIO Driver from official source BEFORE using this library! While the DLL includes an embedded driver as fallback, the official driver provides: β Better stability and reliability β Proper digital signature β Persistent installation (no re-extraction needed) See Quick Start section for installation instructions. π Features Supported Hardware Intel CPU - Temperature monitoring for package and individual cores AMD CPU - Tctl temperature and CCD (Core Complex Die) monitoring NVIDIA GPU - Complete monitoring including temperature, clocks, fan, usage, memory, and power AMD Radeon GPU - Temperature, usage, fan speed monitoring with manual fan control Storage Drives - Temperature monitoring for HDD/SSD/NVMe drives via SMART RAM - Memory usage, speed, voltage, and module information Battery - Comprehensive battery status for laptops (charge, health, capacity, cycles) Motherboard - Super I/O chip monitoring (71 chips supported: ITE, Nuvoton, Winbond, Fintek) Key Capabilities β 88 Functions - Complete hardware monitoring API β JSON Export - Export all hardware data in JSON format β Real-time Monitoring - Live sensor data updates β Fan Control - Manual fan speed control for AMD Radeon GPU and motherboard β Kernel-mode Access - Uses PawnIO driver for low-level hardware access β No Dependencies - Self-contained DLL with embedded resources π Requirements AutoIt 3.3.16.0+ (x64 recommended) Windows 7/8/10/11 Administrator Rights (required for driver installation and hardware access) PawnIO Driver (β οΈ RECOMMENDED: Install official driver first - see installation guide below) π Quick Start PawnIO Driver Installation (Recommended) β οΈ Important: For best performance and reliability, install the official PawnIO driver before using this library. Download PawnIO Driver from official source: GitHub: https://github.com/namazso/PawnIO.Setup/releases Or build from source: https://github.com/namazso/PawnIO Install the driver: REM Run as Administrator sc create PawnIO binPath= "%ProgramFiles%\PawnIO\PawnIO.sys" type= kernel start= demand sc start PawnIO Verify installation: sc query PawnIO Should show STATE: RUNNING Why install official driver? β Better stability - Official driver is tested and signed β Consistent behavior - Same driver version across all apps β Easier updates - Update driver independently β Shared resource - Multiple applications can use same driver β οΈ Embedded driver is fallback only - Extracted to temp, may have permission issues Library Installation Download the latest release Extract files to your project directory Include the UDF in your script: #include "HardwareMonitor.au3" Basic Usage #include "HardwareMonitor.au3" ; Initialize the library If Not _HWMon_Startup() Then MsgBox(0, "Error", "Failed to initialize HardwareMonitor: " & _HWMon_GetLastError()) Exit EndIf ; Check PawnIO driver status (recommended) If Not _HWMon_IsPawnIOInstalled() Then MsgBox(48, "Warning", "PawnIO driver not installed!" & @CRLF & @CRLF & _ "Some features may not work (Intel/AMD CPU temp, motherboard)." & @CRLF & @CRLF & _ "Please install official PawnIO driver from:" & @CRLF & _ "https://github.com/namazso/PawnIO.Setup/releases") EndIf ; Get CPU temperature Local $fTemp = _HWMon_Intel_GetPackageTemp() ConsoleWrite("CPU Temperature: " & $fTemp & "°C" & @CRLF) ; Get GPU information Local $iGPUCount = _HWMon_NVIDIA_GetGPUCount() If $iGPUCount > 0 Then Local $sName = _HWMon_NVIDIA_GetGPUName(0) Local $fGPUTemp = _HWMon_NVIDIA_GetGPUTemp(0) ConsoleWrite("GPU: " & $sName & " - " & $fGPUTemp & "°C" & @CRLF) EndIf ; Export all data to JSON Local $sJSON = _HWMon_GetAllInfoJSON() FileWrite("hardware_data.json", $sJSON) ; Cleanup _HWMon_Shutdown() π Function Reference Core Functions (7) Function Description _HWMon_Startup([$sDLLPath]) Initialize the library _HWMon_Shutdown() Cleanup and close the library _HWMon_IsInitialized() Check if library is initialized βNEWβ _HWMon_IsPawnIOInstalled() Check if PawnIO driver is available βNEWβ _HWMon_GetModuleInfo() Get available hardware modules info _HWMon_GetLastError() Get last error message JSON Export (1) Function Description _HWMon_GetAllInfoJSON() Export all hardware data in JSON format Intel CPU Functions (4) Function Description _HWMon_Intel_GetCoreCount() Get number of CPU cores _HWMon_Intel_GetPackageTemp() Get CPU package temperature _HWMon_Intel_GetCoreTemp($iCoreIndex) Get individual core temperature _HWMon_Intel_GetAllCoreTemps() Get all core temperatures as array AMD CPU Functions (3) Function Description _HWMon_AMD_GetTctlTemp() Get AMD Tctl temperature _HWMon_AMD_GetCCDCount() Get number of CCDs _HWMon_AMD_GetCCDTemp($iCCDIndex) Get CCD temperature NVIDIA GPU Functions (13) Function Description _HWMon_NVIDIA_GetGPUCount() Get number of NVIDIA GPUs _HWMon_NVIDIA_GetGPUName([$iGPUIndex]) Get GPU name _HWMon_NVIDIA_GetGPUTemp([$iGPUIndex]) Get GPU temperature _HWMon_NVIDIA_GetCoreClock([$iGPUIndex]) Get core clock frequency (MHz) _HWMon_NVIDIA_GetMemoryClock([$iGPUIndex]) Get memory clock frequency (MHz) _HWMon_NVIDIA_GetShaderClock([$iGPUIndex]) Get shader clock frequency (MHz) _HWMon_NVIDIA_GetFanSpeed([$iGPUIndex]) Get fan speed (RPM) _HWMon_NVIDIA_GetFanSpeedPercent([$iGPUIndex]) Get fan speed (%) _HWMon_NVIDIA_GetGPUUsage([$iGPUIndex]) Get GPU usage (%) _HWMon_NVIDIA_GetMemoryUsage([$iGPUIndex]) Get memory controller usage (%) _HWMon_NVIDIA_GetVideoEngineUsage([$iGPUIndex]) Get video engine usage (%) _HWMon_NVIDIA_GetMemoryTotal([$iGPUIndex]) Get total VRAM (bytes) _HWMon_NVIDIA_GetMemoryUsed([$iGPUIndex]) Get used VRAM (bytes) _HWMon_NVIDIA_GetMemoryFree([$iGPUIndex]) Get free VRAM (bytes) _HWMon_NVIDIA_GetPowerUsage([$iGPUIndex]) Get power usage (Watts) AMD Radeon GPU Functions (7) Function Description _HWMon_AMDRadeon_GetGPUCount() Get number of AMD GPUs _HWMon_AMDRadeon_GetGPUName([$iGPUIndex]) Get GPU name _HWMon_AMDRadeon_GetGPUTemp([$iGPUIndex]) Get GPU temperature _HWMon_AMDRadeon_GetGPUUsage([$iGPUIndex]) Get GPU usage (%) _HWMon_AMDRadeon_GetFanSpeed([$iGPUIndex]) Get fan speed (RPM) _HWMon_AMDRadeon_GetFanSpeedPercent([$iGPUIndex]) Get fan speed (%) _HWMon_AMDRadeon_SetFanSpeed($iGPUIndex, $iPercent) Set fan speed (0=auto, 30-100%) _HWMon_AMDRadeon_ResetFanToAuto($iGPUIndex) Reset fan to automatic control Storage Functions (4) Function Description _HWMon_Storage_GetDriveCount() Get number of drives _HWMon_Storage_GetDriveModel($iDriveIndex) Get drive model name _HWMon_Storage_GetDriveType($iDriveIndex) Get drive type (HDD/SSD/NVMe) _HWMon_Storage_GetDriveTemp($iDriveIndex) Get drive temperature RAM Monitor Functions (11) Function Description _HWMon_RAM_Initialize() Initialize RAM monitor _HWMon_RAM_Update() Update RAM data _HWMon_RAM_GetTotalMemory() Get total memory (bytes) _HWMon_RAM_GetUsedMemory() Get used memory (bytes) _HWMon_RAM_GetAvailableMemory() Get available memory (bytes) _HWMon_RAM_GetMemoryLoad() Get memory load (%) _HWMon_RAM_GetMemorySpeed() Get RAM speed (MHz) _HWMon_RAM_GetMemoryVoltage() Get RAM voltage (V) _HWMon_RAM_GetModuleCount() Get number of RAM modules _HWMon_RAM_GetModuleInfo($iModuleIndex) Get module info string Battery Monitor Functions (15) Function Description _HWMon_Battery_IsAvailable() Check if battery is available βNEWβ _HWMon_Battery_Initialize() Initialize battery monitor _HWMon_Battery_Update() Update battery data _HWMon_Battery_IsPresent() Check if battery is present _HWMon_Battery_GetStatus() Get battery status string _HWMon_Battery_GetChargeLevel() Get charge level (%) _HWMon_Battery_GetDesignCapacity() Get design capacity (mWh) _HWMon_Battery_GetFullChargeCapacity() Get full charge capacity (mWh) _HWMon_Battery_GetCurrentCapacity() Get current capacity (mWh) _HWMon_Battery_GetHealthPercent() Get battery health (%) _HWMon_Battery_GetVoltage() Get voltage (V) _HWMon_Battery_GetChargeRate() Get charge/discharge rate (W) _HWMon_Battery_GetTimeRemaining() Get time remaining (minutes) _HWMon_Battery_GetTimeToFullCharge() Get time to full charge (minutes) _HWMon_Battery_GetCycleCount() Get battery cycle count Note: _HWMon_Battery_GetManufacturer() has been removed in v2.3.0 (was non-functional). Use WMI if needed: SELECT * FROM Win32_Battery Motherboard Monitor Functions (14) Function Description _HWMon_Motherboard_Initialize() Initialize motherboard monitor _HWMon_Motherboard_Update() Update motherboard data _HWMon_Motherboard_IsDetected() Check if Super I/O chip detected _HWMon_Motherboard_GetChipName() Get Super I/O chip name _HWMon_Motherboard_GetTemperatureCount() Get number of temperature sensors _HWMon_Motherboard_GetTemperature($iIndex) Get temperature value _HWMon_Motherboard_GetTemperatureName($iIndex) Get temperature sensor name _HWMon_Motherboard_GetVoltageCount() Get number of voltage sensors _HWMon_Motherboard_GetVoltage($iIndex) Get voltage value _HWMon_Motherboard_GetVoltageName($iIndex) Get voltage sensor name _HWMon_Motherboard_GetFanCount() Get number of fan sensors _HWMon_Motherboard_GetFanSpeed($iIndex) Get fan speed (RPM) _HWMon_Motherboard_GetFanName($iIndex) Get fan sensor name _HWMon_Motherboard_SetFanSpeed($iIndex, $iPercent) Set fan speed (0=auto, 30-100%) _HWMon_Motherboard_SetFanToAuto($iIndex) Reset fan to automatic control _HWMon_Motherboard_IsFanManualMode($iIndex) Check if fan is in manual mode π‘ Examples Example 1: Monitor CPU Temperature #include "HardwareMonitor.au3" _HWMon_Startup() While True Local $fTemp = _HWMon_Intel_GetPackageTemp() ToolTip("CPU: " & Round($fTemp, 1) & "°C") Sleep(1000) WEnd Example 2: Monitor Multiple GPUs #include "HardwareMonitor.au3" _HWMon_Startup() Local $iGPUCount = _HWMon_NVIDIA_GetGPUCount() ConsoleWrite("Found " & $iGPUCount & " NVIDIA GPU(s)" & @CRLF) For $i = 0 To $iGPUCount - 1 Local $sName = _HWMon_NVIDIA_GetGPUName($i) Local $fTemp = _HWMon_NVIDIA_GetGPUTemp($i) Local $fUsage = _HWMon_NVIDIA_GetGPUUsage($i) Local $fPower = _HWMon_NVIDIA_GetPowerUsage($i) ConsoleWrite("GPU " & $i & ": " & $sName & @CRLF) ConsoleWrite(" Temperature: " & $fTemp & "°C" & @CRLF) ConsoleWrite(" Usage: " & $fUsage & "%" & @CRLF) ConsoleWrite(" Power: " & $fPower & "W" & @CRLF) Next _HWMon_Shutdown() Example 3: Control AMD GPU Fan Speed #include "HardwareMonitor.au3" _HWMon_Startup() ; Set fan to 50% _HWMon_AMDRadeon_SetFanSpeed(0, 50) ConsoleWrite("Fan set to 50%" & @CRLF) Sleep(5000) ; Reset to automatic _HWMon_AMDRadeon_ResetFanToAuto(0) ConsoleWrite("Fan reset to auto" & @CRLF) _HWMon_Shutdown() Example 4: Export All Hardware Data #include "HardwareMonitor.au3" _HWMon_Startup() ; Get all hardware info as JSON Local $sJSON = _HWMon_GetAllInfoJSON() ; Save to file FileWrite(@ScriptDir & "\hardware_report.json", $sJSON) ConsoleWrite("Hardware report saved!" & @CRLF) _HWMon_Shutdown() Example 5: Battery Monitoring (Laptop) #include "HardwareMonitor.au3" _HWMon_Startup() ; Check if battery is available first (NEW in v2.3.0) If _HWMon_Battery_IsAvailable() And _HWMon_Battery_Initialize() Then If _HWMon_Battery_IsPresent() Then Local $fCharge = _HWMon_Battery_GetChargeLevel() Local $sStatus = _HWMon_Battery_GetStatus() Local $fHealth = _HWMon_Battery_GetHealthPercent() Local $iCycles = _HWMon_Battery_GetCycleCount() ConsoleWrite("Battery Status: " & $sStatus & @CRLF) ConsoleWrite("Charge Level: " & $fCharge & "%" & @CRLF) ConsoleWrite("Health: " & $fHealth & "%" & @CRLF) ConsoleWrite("Cycle Count: " & $iCycles & @CRLF) Else ConsoleWrite("No battery detected (Desktop system)" & @CRLF) EndIf EndIf _HWMon_Shutdown() π§ Supported Super I/O Chips (71 Total) The motherboard monitor supports 71 Super I/O chips from major manufacturers: ITE - IT8705F, IT8712F, IT8716F, IT8718F, IT8720F, IT8721F, IT8726F, IT8728F, IT8771E, IT8772E, IT8792E, and more Nuvoton - NCT6771F, NCT6776F, NCT6779D, NCT6791D, NCT6792D, NCT6793D, NCT6795D, NCT6796D, NCT6797D, NCT6798D, and more Winbond - W83627DHG, W83627EHF, W83627HF, W83627THF, W83667HG, W83687THF, and more Fintek - F71858, F71862, F71869, F71882, F71889ED, F71889AD, and more β οΈ Important Notes PawnIO Driver Behavior β οΈ RECOMMENDED APPROACH: Install official PawnIO driver first (see Quick Start section) The library checks for PawnIO driver in this order: Official driver service (RECOMMENDED) Installed via: sc create PawnIO ... Always used if available Best performance and stability Pre-installed driver file Location: %ProgramFiles%\PawnIO\PawnIO.sys (x64) or PawnIO_x86.sys (x86) Used if service not running but file exists DLL will attempt to load it Embedded driver (FALLBACK ONLY) Extracted from DLL resources if above methods fail Saved to %ProgramFiles%\PawnIO\ (requires admin) or temp folder β οΈ Less reliable, may have permission issues Why official driver is better: β Digitally signed and verified β Persistent across reboots β Shared between applications β Easier to update and maintain β No extraction delays β Works without admin rights (after installation) Fan Control Safety When using fan control functions, be aware: 0% = Automatic mode (recommended) 1-29% = Clamped to 30% (safety minimum) 30-100% = Actual speed >100% = Clamped to 100% Always monitor temperatures when using manual fan control! Administrator Rights Administrator rights are required for: PawnIO driver installation (one-time setup) Driver service start (if not set to auto-start) Initial hardware access (MSR, Super I/O chip detection) Recommended setup: Install PawnIO driver as Administrator (one time) Set driver to auto-start: sc config PawnIO start= auto Regular users can then use the library without admin rights If using embedded driver (not recommended): Admin rights required on every run (to extract and load driver) Driver extracted to temp folder (slower, cleaned up periodically) May fail due to antivirus or permission issues Compatibility Intel CPU: Requires MSR (Model Specific Register) support AMD CPU: Ryzen and newer recommended NVIDIA GPU: Requires NVAPI support AMD Radeon GPU: Requires ADL (AMD Display Library) support Motherboard: Requires compatible Super I/O chip π Testing A comprehensive test script is included: #include "test_udf.au3" This will test all 88 functions and generate a detailed report in test_udf.au3.txt. π Troubleshooting PawnIO Driver Issues (Most Common) β οΈ If CPU temperature or motherboard features don't work: Check if PawnIO driver is installed: sc query PawnIO Should show STATE: RUNNING Install official PawnIO driver if not installed: REM Download from "https://github.com/namazso/PawnIO.Setup/releases" first REM Then run as Administrator: sc create PawnIO binPath= "%ProgramFiles%\PawnIO\PawnIO.sys" type= kernel start= demand sc start PawnIO Common PawnIO errors: Error 1275: Driver blocked by Windows β Disable Secure Boot or sign the driver Error 5: Access denied β Run as Administrator Error 1060: Service not found β Driver not installed correctly Error 1058: Cannot start disabled service β Run sc config PawnIO start= demand Verify driver file exists: dir "%ProgramFiles%\PawnIO\PawnIO.sys" Check Windows Event Viewer: Open Event Viewer β Windows Logs β System Look for PawnIO-related errors Using embedded driver (not recommended): DLL will try to extract driver if official not found Requires Administrator rights on every run May fail due to antivirus or security policies Solution: Install official driver instead! "Failed to initialize" error Run as Administrator (required for first run or if PawnIO not installed) Check if DLL exists in correct path Verify Windows version compatibility (Win 7/8/10/11) Install official PawnIO driver (see above) "Motherboard not detected" Ensure PawnIO driver is installed and running Your motherboard may use an unsupported Super I/O chip Check DebugView for detection logs Some laptops don't expose Super I/O chips "Battery not present" on laptop Battery may be removed Some laptops don't expose battery info Try updating ACPI drivers π License This project is provided as-is for educational and personal use. π€ Author Dao Van Trong - TRONG.PRO π Version Version 2.3.0 - Complete hardware monitoring with 88 functions π Statistics Total Functions: 88 (83 base + 5 Intel extended) Core Functions: 7 (includes initialization checks) Battery Functions: 15 (includes availability check) Supported CPUs: Intel (Core series), AMD (Ryzen series) Supported GPUs: NVIDIA (NVAPI), AMD Radeon (ADL) Supported Super I/O Chips: 71 models Code Lines: 1800+ lines of AutoIt code Test Coverage: 100% (all functions tested) Made with β€οΈ for the AutoIt community1 point