Advertisement
AZJIO

info.au3

Apr 22nd, 2018
589
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 6.62 KB | None | 0 0
  1. ;  @AZJIO
  2. ; определяем количество дисков до создания оболочки, ведь от этого зависит её размер
  3. #NoTrayIcon
  4. $DrivesArr = DriveGetDrive("all")
  5. $list = ''
  6. For $i = 1 To $DrivesArr[0]
  7.     $DrTp = DriveGetType($DrivesArr[$i] & '\')
  8.     If $DrTp = 'Removable' Then $DrTp = 'Rem'
  9.     If $DrivesArr[$i] <> 'A:' And $DrTp <> 'CDROM' Then Assign('list', $list & '|' & StringUpper($DrivesArr[$i]) & ' (' & $DrTp & ')')
  10. Next
  11. $aListDrive = StringSplit($list, "|")
  12.  
  13. $xD = @DesktopWidth
  14. GUICreate("Статистика", 267, $aListDrive[0] * 50 + 70, $xD - 277, 30)
  15. If Not @Compiled Then GUISetIcon('shell32.dll', 13)
  16. Dim $progress, $main, $sub
  17.  
  18. $restart = GUICtrlCreateButton("R", 238, 22, 20, 17)
  19. GUICtrlSetTip(-1, "Перезапуск скрипта")
  20.  
  21. $refresh = GUICtrlCreateButton("Re", 10, 80, 20, 17)
  22. GUICtrlSetTip(-1, "Обновить данные харда")
  23.  
  24. $checkHDD = GUICtrlCreateCheckbox("автообновление датчиков HDD", 40, 80, 180, 17)
  25. GUICtrlSetTip(-1, "Обновить данные харда")
  26.  
  27. $mem = MemGetStats()
  28. $ramsize = 'Свободно ' & Round($mem[2] / 1048576, 2) & ' / ' & Round($mem[1] / 1048576, 2) & ' (Гб)'
  29. $ram = _ProgressOn($progress, $main, $sub, "ОЗУ", $ramsize, 10, 5, 1, 0x00f20b, 0xff5c2b)
  30. _ProgressSet($ram, ($mem[1] - $mem[2]) / $mem[1] * 100, "")
  31.  
  32. $sValue = RegRead('HKLM\HARDWARE\DESCRIPTION\System\CentralProcessor\0', 'ProcessorNameString')
  33. $cpu = GUICtrlCreateLabel('CPU: ' & $sValue, 10, 50, 250, 30, 0x0080)
  34. GUICtrlSetFont(-1, -1, 700)
  35.  
  36. For $i = 2 To $aListDrive[0]
  37.     Assign('bykva' & $i, StringLeft($aListDrive[$i], 1))
  38.     Assign('hdd' & $i, _ProgressOn($progress, $main, $sub, $aListDrive[$i] & ' ' & DriveGetFileSystem(Eval('bykva' & $i) & ":\"), 'Свободно ' & Round(DriveSpaceFree(Eval('bykva' & $i) & ":\") / 1024, 1) & ' / ' & Round(DriveSpaceTotal(Eval('bykva' & $i) & ":\") / 1024, 1) & ' (Гб)', 10, $i * 50 + 10, 1, 0xe9e549, 0x2b83ff))
  39.     _ProgressSet(Eval('hdd' & $i), (DriveSpaceTotal(Eval('bykva' & $i) & ":\") - DriveSpaceFree(Eval('bykva' & $i) & ":\")) / DriveSpaceTotal(Eval('bykva' & $i) & ":\") * 100, "")
  40.     Assign('Open' & $i, GUICtrlCreateButton("...", 238, $i * 50 + 27, 20, 18))
  41.     GUICtrlSetTip(-1, "Открыть диск")
  42. Next
  43.  
  44. GUISetState()
  45. $r = 0
  46. $h = 0
  47. While 1
  48.     $msg = GUIGetMsg()
  49.     Sleep(10)
  50.     For $i = 2 To $aListDrive[0]
  51.         If $msg = Eval('Open' & $i) Then ShellExecute(Eval('bykva' & $i) & ":\")
  52.     Next
  53.  
  54.     $r += 1
  55.     If $r = 50 Then ; каждые 0,5 секунд проверка размера памяти
  56.         $r = 0
  57.         $mem = MemGetStats()
  58.         $ramsize = 'Свободно ' & Round($mem[2] / 1048576, 2) & ' / ' & Round($mem[1] / 1048576, 2) & ' (Гб)'
  59.         _ProgressSet($ram, ($mem[1] - $mem[2]) / $mem[1] * 100, $ramsize)
  60.     EndIf
  61.  
  62.     If GUICtrlRead($checkHDD) = 1 Then
  63.         $h += 1
  64.         If $h = 70 Then ; каждые 0,7 секунд проверка хардов, обновление информации
  65.             $h = 0
  66.             For $i = 2 To $aListDrive[0]
  67.                 _ProgressSet(Eval('hdd' & $i), (DriveSpaceTotal(Eval('bykva' & $i) & ":\") - DriveSpaceFree(Eval('bykva' & $i) & ":\")) / DriveSpaceTotal(Eval('bykva' & $i) & ":\") * 100)
  68.             Next
  69.         EndIf
  70.     EndIf
  71.  
  72.     Switch $msg
  73.         Case $refresh
  74.             For $i = 2 To $aListDrive[0]
  75.                 _ProgressSet(Eval('hdd' & $i), (DriveSpaceTotal(Eval('bykva' & $i) & ":\") - DriveSpaceFree(Eval('bykva' & $i) & ":\")) / DriveSpaceTotal(Eval('bykva' & $i) & ":\") * 100)
  76.             Next
  77.         Case $restart
  78.             _restart()
  79.         Case -3
  80.             Exit
  81.     EndSwitch
  82. WEnd
  83.  
  84. ;===============================================================================
  85. ; Создать прогресс, автор функций RazerM
  86. ;===============================================================================
  87. Func _ProgressOn(ByRef $s_mainlabel, ByRef $s_sublabel, ByRef $s_control, $s_main, $s_sub, $x, $y, $fSmooth = 0, $BkCol = 0xE0DFE3, $Color = 0xB2B4BF)
  88.     $s_mainlabel = GUICtrlCreateLabel($s_main, $x, $y, StringLen($s_main) * 9, 17)
  89.     GUICtrlSetFont(-1, -1, 700)
  90.     If $s_mainlabel = 0 Then
  91.         SetError(1)
  92.         Return 0
  93.     EndIf
  94.     If StringInStr(@OSType, "WIN32_NT") And $fSmooth = 1 Then
  95.         $prev = DllCall("uxtheme.dll", "int", "GetThemeAppProperties");, "int", 0)
  96.         DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0)
  97.     EndIf
  98.     $s_control = GUICtrlCreateProgress($x, $y + 17, 220, 17, 1)
  99.     GUICtrlSetColor(-1, $Color)
  100.     GUICtrlSetBkColor(-1, $BkCol)
  101.     If StringInStr(@OSType, "WIN32_NT") And $fSmooth = 1 Then
  102.         DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", $prev[0])
  103.     EndIf
  104.     If $s_control = 0 Then
  105.         SetError(1)
  106.         Return 0
  107.     EndIf
  108.     $s_sublabel = GUICtrlCreateLabel($s_sub, $x + 105, $y, 17)
  109.     GUICtrlSetFont(-1, -1, 700)
  110.     If $s_sublabel = 0 Then
  111.         SetError(1)
  112.         Return 0
  113.     EndIf
  114.     Dim $a_info[5]
  115.     $a_info[0] = $s_control
  116.     $a_info[1] = $s_mainlabel
  117.     $a_info[2] = $s_sublabel
  118.     $a_info[3] = $x
  119.     $a_info[4] = $y
  120.     Return $a_info
  121. EndFunc
  122. ;===============================================================================
  123. ; установка параметров, автор функций RazerM  (слегка модифицировано)
  124. ;===============================================================================
  125. ;
  126. Func _ProgressSet($a_info, $i_per, $s_sub = "", $s_main = "")
  127.     If $s_main = "" Then $s_main = GUICtrlRead($a_info[1])
  128.     If $s_sub = "" Then $s_sub = GUICtrlRead($a_info[2])
  129.     $set1 = GUICtrlSetData($a_info[0], $i_per)
  130.     $set2 = GUICtrlSetData($a_info[1], $s_main)
  131.     $set3 = GUICtrlSetData($a_info[2], $s_sub)
  132.     GUICtrlSetPos($a_info[2], $a_info[3] + 105, $a_info[4], StringLen($s_sub) * 6, 17)
  133.     GUICtrlSetPos($a_info[1], $a_info[3], $a_info[4], StringLen($s_main) * 7)
  134.     If ($set1 = 0) Or ($set2 = 0) Or ($set3 = 0) Or ($set1 = -1) Or ($set2 = -1) Or ($set3 = -1) Then
  135.         SetError(1)
  136.         Return 0
  137.     EndIf
  138.     Return 1
  139. EndFunc
  140.  
  141. Func _restart()
  142.     Local $sAutoIt_File = @TempDir & "\~Au3_ScriptRestart_TempFile.au3"
  143.     Local $sRunLine, $sScript_Content, $hFile
  144.  
  145.     $sRunLine = @ScriptFullPath
  146.     If Not @Compiled Then $sRunLine = @AutoItExe & ' /AutoIt3ExecuteScript ""' & $sRunLine & '""'
  147.     If $CmdLine[0] > 0 Then $sRunLine &= ' ' & $CmdLineRaw
  148.  
  149.     $sScript_Content &= '#NoTrayIcon' & @CRLF
  150.     $sScript_Content &= 'While ProcessExists(' & @AutoItPID & ')' & @CRLF
  151.     $sScript_Content &= '   Sleep(10)' & @CRLF
  152.     $sScript_Content &= 'WEnd' & @CRLF
  153.     $sScript_Content &= 'Run("' & $sRunLine & '")' & @CRLF
  154.     $sScript_Content &= 'FileDelete(@ScriptFullPath)' & @CRLF
  155.  
  156.     $hFile = FileOpen($sAutoIt_File, 2)
  157.     FileWrite($hFile, $sScript_Content)
  158.     FileClose($hFile)
  159.  
  160.     Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & $sAutoIt_File & '"', @ScriptDir, @SW_HIDE)
  161.     Sleep(1000)
  162.     Exit
  163. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement