Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Memory.au3>
- ; - "Inspired" by this script http://www.autoit.de/index.php?page=Thread&postID=250736#post250736 (written by Andy)
- ; - Author: name22 (www.autoit.de)
- #Region Structure Definitions
- Global Const $tagAdapterInfo = "int iSize;" & _
- "int iAdapterIndex;" & _
- "char strUDID[256];" & _
- "int iBusNumber;" & _
- "int iDeviceNumber;" & _
- "int iFunctionNumber;" & _
- "int iVendorID;" & _
- "char strAdapterName[256];" & _
- "char strDisplayName[256];" & _
- "int iPresent;" & _
- "int iExist;" & _
- "char strDriverPath[256];" & _
- "char strDriverPathExt[256];" & _
- "char strPNPString[256];" & _
- "int iOSDisplayIndex"
- Global Const $tagADLPMActivity = "int iSize;" & _
- "int iEngineClock;" & _
- "int iMemoryClock;" & _
- "int iVddc;" & _
- "int iActivityPercent;" & _
- "int iCurrentPerformanceLevel;" & _
- "int iCurrentBusSpeed;" & _
- "int iCurrentBusLanes;" & _
- "int iMaximumBusLanes;" & _
- "int iReserved"
- #EndRegion
- Global $sDLL_ADL, $hCallback_Alloc, $pCallback_Alloc, $iNumberAdapters, $aAdapterInfo, $tBuffer, $tActivity
- OnAutoItExitRegister("_Shutdown")
- $hDLL_ADL = DllOpen("atiadlxx.dll")
- If $hDLL_ADL = -1 Then $hDLL_ADL = DllOpen("atiadlxy.dll")
- $hCallback_Alloc = DllCallbackRegister("_Main_Memory_Alloc", "int_ptr", "int")
- $pCallback_Alloc = DllCallbackGetPtr($hCallback_Alloc)
- _ADL_Main_Control_Create($pCallback_Alloc)
- $iNumberAdapters = _ADL_Adapter_NumberOfAdapters_Get()
- If $iNumberAdapters > 0 Then
- $aAdapterInfo = _ADL_Adapter_AdapterInfo_Get($iNumberAdapters)
- For $i = 0 To UBound($aAdapterInfo) - 1
- $tActivity = _ADL_Overdrive5_CurrentActivity_Get($aAdapterInfo[$i].iAdapterIndex)
- ConsoleWrite("GPU " & $i + 1 & ". " & $aAdapterInfo[$i].strAdapterName & ": Activity [%] =" & @TAB & $tActivity.iActivityPercent & @CRLF)
- Next
- EndIf
- Func _Main_Memory_Alloc($iSize)
- ConsoleWrite("!Global_Mem_Alloc:" & @TAB & $iSize & @CRLF)
- Return _MemGlobalAlloc($iSize)
- EndFunc
- Func _Main_Memory_Free($pMem)
- ConsoleWrite("!Global_Mem_Free:" & @TAB & $pMem & @CRLF)
- Return _MemGlobalFree($pMem)
- EndFunc
- Func _Shutdown()
- _ADL_Main_Control_Destroy()
- DllCallbackFree($hCallback_Alloc)
- DllClose($hDLL_ADL)
- EndFunc
- #Region ADL-DLL Functions
- Func _ADL_Main_Control_Create($pMemAlloc, $iEnumConnectedAdapters = 0)
- $aRet = DllCall($hDLL_ADL, "int:cdecl", "ADL_Main_Control_Create", "ptr", $pCallback_Alloc, "int", $iEnumConnectedAdapters)
- If Not @error Then
- Return $aRet[0]
- Else
- Return SetError(@error, 0, 0)
- EndIf
- EndFunc
- Func _ADL_Main_Control_Destroy()
- $aRet = DllCall($hDLL_ADL, "int:cdecl", "ADL_Main_Control_Destroy")
- If Not @error Then
- Return $aRet[0]
- Else
- Return SetError(@error, 0, 0)
- EndIf
- EndFunc
- Func _ADL_Adapter_NumberOfAdapters_Get()
- Local $iNumberAdapters
- $aRet = DllCall($hDLL_ADL, "int:cdecl", "ADL_Adapter_NumberOfAdapters_Get", "int*", $iNumberAdapters)
- If Not @error Then
- Return $aRet[1]
- Else
- Return SetError(@error, 0, 0)
- EndIf
- EndFunc
- Func _ADL_Adapter_AdapterInfo_Get($iNumberAdapters)
- Local $iStructSize = DllStructGetSize(DllStructCreate($tagAdapterInfo))
- $tBuffer = DllStructCreate("byte[" & $iStructSize * $iNumberAdapters & "]")
- Local $pBuffer = DllStructGetPtr($tBuffer)
- Local $aAdapterInfo[$iNumberAdapters]
- For $i = 0 To $iNumberAdapters - 1
- $aAdapterInfo[$i] = DllStructCreate($tagAdapterInfo, $pBuffer + $i * $iStructSize)
- Next
- $aRet = DllCall($hDLL_ADL, "int:cdecl", "ADL_Adapter_AdapterInfo_Get", "ptr", $pBuffer, "int", DllStructGetSize($tBuffer))
- If Not @error Then
- Return $aAdapterInfo
- Else
- Return SetError(@error, 0, 0)
- EndIf
- EndFunc
- Func _ADL_Overdrive5_CurrentActivity_Get($iAdapterIndex)
- Local $tADLPMActivity = DllStructCreate($tagADLPMActivity), $pADLPMActivity = DllStructGetPtr($tADLPMActivity)
- $tADLPMActivity.iSize = DllStructGetSize($tADLPMActivity)
- $aRet = DllCall($hDLL_ADL, "int:cdecl", "ADL_Overdrive5_CurrentActivity_Get", "int", $iAdapterIndex, "ptr", $pADLPMActivity)
- If Not @error Then
- Return $tADLPMActivity
- Else
- Return SetError(@error, 0, 0)
- EndIf
- EndFunc
- #EndRegion
Add Comment
Please, Sign In to add comment