#include <File.au3>
#include <GUIConstantsEx.au3>
#include <GUIImageList.au3>
#include <GUITreeView.au3>
#include <TreeViewConstants.au3>
#include <WindowsConstants.au3>
#Include <WinAPIEx.au3>
Global $Time1 = 0, $Time2 = 0
Global Const $sRoot = @TempDir;'C:\Temp';@DesktopDir
Global Const $sRoot2 =@ScriptDir;@ProgramFilesDir
Global Const $sRoot3 = @DesktopDir
$hForm = GUICreate('MyGUI', 230, 810,@DesktopHeight +50,0)
$Label = GUICtrlCreateLabel('0%', 0, 0, 40, 14)
GUICtrlCreateTreeView(0, 0, 230, 270, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
$hTreeView = GUICtrlGetHandle(-1)
GUICtrlCreateTreeView(0, 272, 230, 268, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
$hTreeView2 = GUICtrlGetHandle(-1)
GUICtrlCreateTreeView(0, 541, 230, 268, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
$hTreeView3 = GUICtrlGetHandle(-1)
; Windows Vista/7
DllCall('uxtheme.dll', 'uint', 'SetWindowTheme', 'hwnd', $hTreeView, 'wstr', 'Explorer', 'ptr', 0)
$hImageList = _GUIImageList_Create(16, 16, 5, 1)
_GUIImageList_AddIcon($hImageList, @SystemDir & '\shell32.dll', 3)
_GUIImageList_AddIcon($hImageList, @SystemDir & '\shell32.dll', 4)
_GUIImageList_AddIcon($hImageList, @SystemDir & '\shell32.dll', 0)
_GUICtrlTreeView_SetNormalImageList($hTreeView, $hImageList)
_GUICtrlTreeView_BeginUpdate($hTreeView)
_GUICtrlTreeView_EnumDir($hTreeView, $sRoot)
_GUICtrlTreeView_SetState($hTreeView, _GUICtrlTreeView_GetFirstItem($hTreeView), $TVIS_EXPANDED, 1)
_GUICtrlTreeView_EndUpdate($hTreeView)
_GUICtrlTreeView_SetNormalImageList($hTreeView2, $hImageList)
_GUICtrlTreeView_BeginUpdate($hTreeView2)
_GUICtrlTreeView_EnumDir($hTreeView2, $sRoot2)
_GUICtrlTreeView_SetState($hTreeView2, _GUICtrlTreeView_GetFirstItem($hTreeView2), $TVIS_EXPANDED, 1)
_GUICtrlTreeView_EndUpdate($hTreeView2)
_GUICtrlTreeView_SetNormalImageList($hTreeView3, $hImageList)
_GUICtrlTreeView_BeginUpdate($hTreeView3)
_GUICtrlTreeView_EnumDir($hTreeView3, $sRoot3)
_GUICtrlTreeView_SetState($hTreeView3, _GUICtrlTreeView_GetFirstItem($hTreeView3), $TVIS_EXPANDED, 1)
_GUICtrlTreeView_EndUpdate($hTreeView3)
GUIRegisterMsg($WM_NOTIFY, 'WM_NOTIFY')
GUISetState()
AdlibRegister('_CPU', 1000)
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
Func _FileGetIcon($sFile, $iFixIconID = 1)
Local $iOld_Opt_EES = Opt("ExpandEnvStrings", 1)
Local $sRegDefault = "", $sDefIcon = "", $sExecutable, $sExt, $a_LinkInfo, $s_TargetFile, $s_IconFile, $hSearch, $sIconFile
Local $nIcon = 0, $iError = 0, $aRet[3]
If StringInStr(FileGetAttrib($sFile & "\"), "D") Then
$sRegDefault = RegRead("HKCR\Folder", "")
If $sRegDefault <> "" Then
$sDefIcon = RegRead("HKCR\Folder\DefaultIcon", "")
EndIf
Else
$sExt = StringRegExpReplace($sFile, '^.*\.', '.')
If $sExt = ".exe" And FileExists($sFile) Then
Opt("ExpandEnvStrings", $iOld_Opt_EES)
If _WinAPI_ExtractIconEx($sFile, 0, 0, 0, 1) = 0 Then
$sFile = @SystemDir & '\shell32.dll'
$nIcon = -3
EndIf
If $iFixIconID Then
$nIcon = -($nIcon + ($nIcon > 0))
EndIf
Dim $aRet[3] = [2, $sFile, $nIcon]
Return $aRet
EndIf
If $sExt = ".lnk" Then
$aLinkInfo = FileGetShortcut($sFile)
If Not @error Then
$s_TargetFile = $aLinkInfo[0]
$s_IconFile = $aLinkInfo[4]
Opt("ExpandEnvStrings", $iOld_Opt_EES)
If Not FileExists($s_IconFile) Then
$a_LinkInfo = _FileGetIcon($s_TargetFile, 0)
If Not @error Then
$aLinkInfo[4] = $a_LinkInfo[1]
$aLinkInfo[5] = $a_LinkInfo[2]
EndIf
EndIf
If $iFixIconID Then
$aLinkInfo[5] = -($aLinkInfo[5] + ($aLinkInfo[5] > 0))
EndIf
Dim $aRet[3] = [2, $aLinkInfo[4], $aLinkInfo[5]]
Return $aRet
EndIf
EndIf
If $sExt = $sFile Then
$hSearch = FileFindFirstFile($sFile & ".*")
$sExt = StringRegExpReplace(FileFindNextFile($hSearch), '^.*\.', '.')
$sFile &= $sExt
FileClose($hSearch)
EndIf
$sRegDefault = RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\" & $sExt, "ProgID")
If $sRegDefault = "" Then
$sRegDefault = RegRead("HKCR\" & $sExt, "")
EndIf
If $sRegDefault <> "" Then
$sDefIcon = RegRead("HKCR\" & $sRegDefault & "\DefaultIcon", "")
If $sDefIcon = "" Then
$sDefIcon = RegRead("HKCR\" & $sExt & "\DefaultIcon", "")
EndIf
Else
$sRegDefault = RegRead("HKCR\" & $sExt, "PerceivedType")
If $sRegDefault <> "" Then
$sRegDefault = RegRead("HKCR\SystemFileAssociations\" & $sRegDefault & "\DefaultIcon", "")
EndIf
EndIf
EndIf
If $sDefIcon = "" And $sRegDefault <> "" Then
$sDefIcon = RegRead("HKCR\" & $sRegDefault & "\CurVer", "") ; ADOBE PERVERSION....
If $sDefIcon Then
$sDefIcon = RegRead("HKCR\" & $sDefIcon & "\DefaultIcon", "")
Else
$sDefIcon = RegRead("HKCR\" & $sRegDefault & "\shell\open\command", "")
$sDefIcon = StringReplace($sDefIcon, ' "%1"', '')
EndIf
EndIf
If $sDefIcon = "" Then
$sIconFile = @SystemDir & "\shell32.dll"
ElseIf Not StringRegExp($sDefIcon, '\A"*%1"*\z') Then
If StringRegExpReplace($sFile, "^.*\\", "") = "shell32.dll" Then
$sIconFile = $sFile
$nIcon = 0
Else
Local $aDefIconSplit = StringSplit($sDefIcon, ",")
If IsArray($aDefIconSplit) Then
$sIconFile = $aDefIconSplit[1]
If $aDefIconSplit[0] > 1 Then
$nIcon = $aDefIconSplit[2]
EndIf
Else
$iError = 1
EndIf
EndIf
Else
$sIconFile = -1 ;$sFile
$nIcon = 0
EndIf
If Not FileExists($sIconFile) And Not FileExists(@SystemDir & "\" & $sIconFile) Then
$sExecutable = _WinAPI_FindExecutable($sFile)
If FileExists($sExecutable) Then
$sIconFile = $sExecutable
Else
$sExecutable = _WinAPI_PathFindOnPath($sIconFile)
If FileExists($sExecutable) Then
$sIconFile = $sExecutable
EndIf
EndIf
ElseIf FileExists(@SystemDir & "\" & $sIconFile) Then
$sIconFile = @SystemDir & "\" & $sIconFile
EndIf
Opt("ExpandEnvStrings", $iOld_Opt_EES)
If $iFixIconID Then
$nIcon = -($nIcon + ($nIcon > 0))
EndIf
If Not FileExists($sIconFile) Then
$iError = 1
EndIf
Dim $aRet[3] = [2, StringRegExpReplace($sIconFile, '\A"+|"+\z', ''), $nIcon]
Return SetError($iError, 0, $aRet)
EndFunc
Func _FileGetIcon2($sFile, $iFixIconID = 1)
Local $iOld_Opt_EES = Opt("ExpandEnvStrings", 1)
Local $sRegDefault = "", $sDefIcon = "", $sExecutable, $sExt, $a_LinkInfo, $s_TargetFile, $s_IconFile, $hSearch, $sIconFile
Local $nIcon = 0, $iError = 0, $aRet[3]
If StringInStr(FileGetAttrib($sFile & "\"), "D") Then
$sRegDefault = RegRead("HKCR\Folder", "")
If $sRegDefault <> "" Then
$sDefIcon = RegRead("HKCR\Folder\DefaultIcon", "")
EndIf
Else
$sExt = StringRegExpReplace($sFile, '^.*\.', '.')
If $sExt = ".exe" And FileExists($sFile) Then
Opt("ExpandEnvStrings", $iOld_Opt_EES)
If _WinAPI_ExtractIconEx($sFile, 0, 0, 0, 1) = 0 Then
$sFile = @SystemDir & '\shell32.dll'
$nIcon = -3
EndIf
If $iFixIconID Then
$nIcon = -($nIcon + ($nIcon > 0))
EndIf
Dim $aRet[3] = [2, $sFile, $nIcon]
Return $aRet
EndIf
If $sExt = ".lnk" Then
$aLinkInfo = FileGetShortcut($sFile)
If Not @error Then
$s_TargetFile = $aLinkInfo[0]
$s_IconFile = $aLinkInfo[4]
Opt("ExpandEnvStrings", $iOld_Opt_EES)
If Not FileExists($s_IconFile) Then
$a_LinkInfo = _FileGetIcon($s_TargetFile, 0)
If Not @error Then
$aLinkInfo[4] = $a_LinkInfo[1]
$aLinkInfo[5] = $a_LinkInfo[2]
EndIf
EndIf
If $iFixIconID Then
$aLinkInfo[5] = -($aLinkInfo[5] + ($aLinkInfo[5] > 0))
EndIf
Dim $aRet[3] = [2, $aLinkInfo[4], $aLinkInfo[5]]
Return $aRet
EndIf
EndIf
If $sExt = $sFile Then
$hSearch = FileFindFirstFile($sFile & ".*")
$sExt = StringRegExpReplace(FileFindNextFile($hSearch), '^.*\.', '.')
$sFile &= $sExt
FileClose($hSearch)
EndIf
$sRegDefault = RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\" & $sExt, "ProgID")
If $sRegDefault = "" Then
$sRegDefault = RegRead("HKCR\" & $sExt, "")
EndIf
If $sRegDefault <> "" Then
$sDefIcon = RegRead("HKCR\" & $sRegDefault & "\DefaultIcon", "")
If $sDefIcon = "" Then
$sDefIcon = RegRead("HKCR\" & $sExt & "\DefaultIcon", "")
EndIf
Else
$sRegDefault = RegRead("HKCR\" & $sExt, "PerceivedType")
If $sRegDefault <> "" Then
$sRegDefault = RegRead("HKCR\SystemFileAssociations\" & $sRegDefault & "\DefaultIcon", "")
EndIf
EndIf
EndIf
If $sDefIcon = "" And $sRegDefault <> "" Then
$sDefIcon = RegRead("HKCR\" & $sRegDefault & "\CurVer", "") ; ADOBE PERVERSION....
If $sDefIcon Then
$sDefIcon = RegRead("HKCR\" & $sDefIcon & "\DefaultIcon", "")
Else
$sDefIcon = RegRead("HKCR\" & $sRegDefault & "\shell\open\command", "")
$sDefIcon = StringReplace($sDefIcon, ' "%1"', '')
EndIf
EndIf
If $sDefIcon = "" Then
$sIconFile = @SystemDir & "\shell32.dll"
ElseIf Not StringRegExp($sDefIcon, '\A"*%1"*\z') Then
If StringRegExpReplace($sFile, "^.*\\", "") = "shell32.dll" Then
$sIconFile = $sFile
$nIcon = 0
Else
Local $aDefIconSplit = StringSplit($sDefIcon, ",")
If IsArray($aDefIconSplit) Then
$sIconFile = $aDefIconSplit[1]
If $aDefIconSplit[0] > 1 Then
$nIcon = $aDefIconSplit[2]
EndIf
Else
$iError = 1
EndIf
EndIf
Else
$sIconFile = -1 ;$sFile
$nIcon = 0
EndIf
If Not FileExists($sIconFile) And Not FileExists(@SystemDir & "\" & $sIconFile) Then
$sExecutable = _WinAPI_FindExecutable($sFile)
If FileExists($sExecutable) Then
$sIconFile = $sExecutable
Else
$sExecutable = _WinAPI_PathFindOnPath($sIconFile)
If FileExists($sExecutable) Then
$sIconFile = $sExecutable
EndIf
EndIf
ElseIf FileExists(@SystemDir & "\" & $sIconFile) Then
$sIconFile = @SystemDir & "\" & $sIconFile
EndIf
Opt("ExpandEnvStrings", $iOld_Opt_EES)
If $iFixIconID Then
$nIcon = -($nIcon + ($nIcon > 0))
EndIf
If Not FileExists($sIconFile) Then
$iError = 1
EndIf
Dim $aRet[3] = [2, StringRegExpReplace($sIconFile, '\A"+|"+\z', ''), $nIcon]
Return SetError($iError, 0, $aRet)
EndFunc
Func _FileGetIcon3($sFile, $iFixIconID = 1)
Local $iOld_Opt_EES = Opt("ExpandEnvStrings", 1)
Local $sRegDefault = "", $sDefIcon = "", $sExecutable, $sExt, $a_LinkInfo, $s_TargetFile, $s_IconFile, $hSearch, $sIconFile
Local $nIcon = 0, $iError = 0, $aRet[3]
If StringInStr(FileGetAttrib($sFile & "\"), "D") Then
$sRegDefault = RegRead("HKCR\Folder", "")
If $sRegDefault <> "" Then
$sDefIcon = RegRead("HKCR\Folder\DefaultIcon", "")
EndIf
Else
$sExt = StringRegExpReplace($sFile, '^.*\.', '.')
If $sExt = ".exe" And FileExists($sFile) Then
Opt("ExpandEnvStrings", $iOld_Opt_EES)
If _WinAPI_ExtractIconEx($sFile, 0, 0, 0, 1) = 0 Then
$sFile = @SystemDir & '\shell32.dll'
$nIcon = -3
EndIf
If $iFixIconID Then
$nIcon = -($nIcon + ($nIcon > 0))
EndIf
Dim $aRet[3] = [2, $sFile, $nIcon]
Return $aRet
EndIf
If $sExt = ".lnk" Then
$aLinkInfo = FileGetShortcut($sFile)
If Not @error Then
$s_TargetFile = $aLinkInfo[0]
$s_IconFile = $aLinkInfo[4]
Opt("ExpandEnvStrings", $iOld_Opt_EES)
If Not FileExists($s_IconFile) Then
$a_LinkInfo = _FileGetIcon($s_TargetFile, 0)
If Not @error Then
$aLinkInfo[4] = $a_LinkInfo[1]
$aLinkInfo[5] = $a_LinkInfo[2]
EndIf
EndIf
If $iFixIconID Then
$aLinkInfo[5] = -($aLinkInfo[5] + ($aLinkInfo[5] > 0))
EndIf
Dim $aRet[3] = [2, $aLinkInfo[4], $aLinkInfo[5]]
Return $aRet
EndIf
EndIf
If $sExt = $sFile Then
$hSearch = FileFindFirstFile($sFile & ".*")
$sExt = StringRegExpReplace(FileFindNextFile($hSearch), '^.*\.', '.')
$sFile &= $sExt
FileClose($hSearch)
EndIf
$sRegDefault = RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\" & $sExt, "ProgID")
If $sRegDefault = "" Then
$sRegDefault = RegRead("HKCR\" & $sExt, "")
EndIf
If $sRegDefault <> "" Then
$sDefIcon = RegRead("HKCR\" & $sRegDefault & "\DefaultIcon", "")
If $sDefIcon = "" Then
$sDefIcon = RegRead("HKCR\" & $sExt & "\DefaultIcon", "")
EndIf
Else
$sRegDefault = RegRead("HKCR\" & $sExt, "PerceivedType")
If $sRegDefault <> "" Then
$sRegDefault = RegRead("HKCR\SystemFileAssociations\" & $sRegDefault & "\DefaultIcon", "")
EndIf
EndIf
EndIf
If $sDefIcon = "" And $sRegDefault <> "" Then
$sDefIcon = RegRead("HKCR\" & $sRegDefault & "\CurVer", "") ; ADOBE PERVERSION....
If $sDefIcon Then
$sDefIcon = RegRead("HKCR\" & $sDefIcon & "\DefaultIcon", "")
Else
$sDefIcon = RegRead("HKCR\" & $sRegDefault & "\shell\open\command", "")
$sDefIcon = StringReplace($sDefIcon, ' "%1"', '')
EndIf
EndIf
If $sDefIcon = "" Then
$sIconFile = @SystemDir & "\shell32.dll"
ElseIf Not StringRegExp($sDefIcon, '\A"*%1"*\z') Then
If StringRegExpReplace($sFile, "^.*\\", "") = "shell32.dll" Then
$sIconFile = $sFile
$nIcon = 0
Else
Local $aDefIconSplit = StringSplit($sDefIcon, ",")
If IsArray($aDefIconSplit) Then
$sIconFile = $aDefIconSplit[1]
If $aDefIconSplit[0] > 1 Then
$nIcon = $aDefIconSplit[2]
EndIf
Else
$iError = 1
EndIf
EndIf
Else
$sIconFile = -1 ;$sFile
$nIcon = 0
EndIf
If Not FileExists($sIconFile) And Not FileExists(@SystemDir & "\" & $sIconFile) Then
$sExecutable = _WinAPI_FindExecutable($sFile)
If FileExists($sExecutable) Then
$sIconFile = $sExecutable
Else
$sExecutable = _WinAPI_PathFindOnPath($sIconFile)
If FileExists($sExecutable) Then
$sIconFile = $sExecutable
EndIf
EndIf
ElseIf FileExists(@SystemDir & "\" & $sIconFile) Then
$sIconFile = @SystemDir & "\" & $sIconFile
EndIf
Opt("ExpandEnvStrings", $iOld_Opt_EES)
If $iFixIconID Then
$nIcon = -($nIcon + ($nIcon > 0))
EndIf
If Not FileExists($sIconFile) Then
$iError = 1
EndIf
Dim $aRet[3] = [2, StringRegExpReplace($sIconFile, '\A"+|"+\z', ''), $nIcon]
Return SetError($iError, 0, $aRet)
EndFunc
Func _GUICtrlTreeView_EnumDir($hWnd, $sRoot, $hItem = 0)
Local $hSubItem, $sItem, $aList
$sRoot = StringRegExpReplace($sRoot, '\\+\Z', '')
$sItem = StringRegExpReplace($sRoot, '^.*\\', '')
If StringRight($sItem, 1) = ':' Then
$sItem &= '\'
EndIf
$hSubItem = _GUICtrlTreeView_AddChild($hWnd, $hItem, $sItem, 0, 1)
$aList = _FileListToArray($sRoot, '*', 2)
If Not @error Then
For $i = 1 To $aList[0]
_GUICtrlTreeView_EnumDir($hWnd, $sRoot & '\' & $aList[$i], $hSubItem)
Next
EndIf
; Если нужен список файлов
$aList = _FileListToArray($sRoot, '*', 1)
If Not @error Then
For $i = 1 To $aList[0]
$aIcon = _FileGetIcon($sRoot & '\' & $aList[$i], 0)
If Not @error Then
$iIcon = _GUIImageList_AddIcon($hImageList, $aIcon[1], $aIcon[2])
Else
$iIcon = 2
EndIf
_GUICtrlTreeView_AddChild($hWnd, $hSubItem, $aList[$i], $iIcon, $iIcon)
Next
EndIf
EndFunc
Func _GUICtrlTreeView_EnumDir2($hWnd, $sRoot2, $hItem = 0)
Local $hSubItem, $sItem, $aList
$sRoot2 = StringRegExpReplace($sRoot2, '\\+\Z', '')
$sItem = StringRegExpReplace($sRoot2, '^.*\\', '')
If StringRight($sItem, 1) = ':' Then
$sItem &= '\'
EndIf
$hSubItem = _GUICtrlTreeView_AddChild($hWnd, $hItem, $sItem, 0, 1)
$aList = _FileListToArray($sRoot2, '*', 2)
If Not @error Then
For $i = 1 To $aList[0]
_GUICtrlTreeView_EnumDir2($hWnd, $sRoot2 & '\' & $aList[$i], $hSubItem)
Next
EndIf
; Если нужен список файлов
$aList = _FileListToArray($sRoot2, '*', 1)
If Not @error Then
For $i = 1 To $aList[0]
$aIcon = _FileGetIcon2($sRoot2 & '\' & $aList[$i], 0)
If Not @error Then
$iIcon = _GUIImageList_AddIcon($hImageList, $aIcon[1], $aIcon[2])
Else
$iIcon = 2
EndIf
_GUICtrlTreeView_AddChild($hWnd, $hSubItem, $aList[$i], $iIcon, $iIcon)
Next
EndIf
EndFunc
Func _GUICtrlTreeView_EnumDir3($hWnd, $sRoot3, $hItem = 0)
Local $hSubItem, $sItem, $aList
$sRoot3 = StringRegExpReplace($sRoot3, '\\+\Z', '')
$sItem = StringRegExpReplace($sRoot3, '^.*\\', '')
If StringRight($sItem, 1) = ':' Then
$sItem &= '\'
EndIf
$hSubItem = _GUICtrlTreeView_AddChild($hWnd, $hItem, $sItem, 0, 1)
$aList = _FileListToArray($sRoot3, '*', 2)
If Not @error Then
For $i = 1 To $aList[0]
_GUICtrlTreeView_EnumDir3($hWnd, $sRoot3 & '\' & $aList[$i], $hSubItem)
Next
EndIf
; Если нужен список файлов
$aList = _FileListToArray($sRoot3, '*', 1)
If Not @error Then
For $i = 1 To $aList[0]
$aIcon = _FileGetIcon3($sRoot3 & '\' & $aList[$i], 0)
If Not @error Then
$iIcon = _GUIImageList_AddIcon($hImageList, $aIcon[1], $aIcon[2])
Else
$iIcon = 2
EndIf
_GUICtrlTreeView_AddChild($hWnd, $hSubItem, $aList[$i], $iIcon, $iIcon)
Next
EndIf
EndFunc
Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
Local $tNMTREEVIEW = DllStructCreate($tagNMTREEVIEW, $lParam)
Local $hTV = DllStructGetData($tNMTREEVIEW, 'hWndFrom')
Local $ID = DllStructGetData($tNMTREEVIEW, 'Code')
Switch $hTV
Case $hTreeView
Switch $ID
Case $TVN_ITEMEXPANDEDA, $TVN_ITEMEXPANDEDW
_GUICtrlTreeView_SetImageIndex($hTreeView, _
DllStructGetData($tNMTREEVIEW, 'NewhItem'), _
BitAND(DllStructGetData($tNMTREEVIEW, 'NewState'), $TVIS_EXPANDED) = $TVIS_EXPANDED)
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
Func _CPU()
Local $Time2 = _WinAPI_GetSystemTimes()
If IsArray($Time1) Then
$TimeBusyCPU = ($Time2[1] + $Time2[2]) - ($Time1[1] + $Time1[2])
$TimeIdleCPU = ($Time2[0] - $Time1[0])
GUICtrlSetData($Label, StringFormat('%.f%', ($TimeBusyCPU - $TimeIdleCPU) / $TimeBusyCPU * 100))
$menustate = GUICtrlRead($Label)
TrayTip("", $menustate, 5)
EndIf
$Time1 = $Time2
EndFunc ;==>_CPU