Advertisement
AZJIO

ChkDskGui_mini

Jan 25th, 2013
607
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 3.06 KB | None | 0 0
  1. $LngTitle = 'Check Disk'
  2. $LngCh1 = 'Fix disk errors'
  3. $LngCh2 = 'Recovering bad sectors'
  4. $LngCh3 = 'Forced dismount volume'
  5. $LngBtn = 'Start'
  6.  
  7. If @OSLang = 0419 Then
  8.     ; $LngTitle = 'Проверка дисков'
  9.     $LngCh1 = 'Исправление ошибок на диске'
  10.     $LngCh2 = 'Восстановление поврежденных секторов'
  11.     $LngCh3 = 'Принудительное отключение тома'
  12.     $LngBtn = 'Старт'
  13. EndIf
  14.  
  15. #NoTrayIcon
  16. Opt("GUIOnEventMode", 1)
  17. $sp = Chr(1)
  18. Opt("GUIDataSeparatorChar", $sp)
  19. $iGui = GUICreate($LngTitle, 250, 117)
  20. GUISetIcon(@ScriptDir & '\ChkDskGui.ico')
  21. GUISetOnEvent(-3, "_Form1Close")
  22. $iCheckbox1 = GUICtrlCreateCheckbox($LngCh1, 10, 10, 240, 20)
  23. GUICtrlSetState(-1, 1)
  24. $iCheckbox2 = GUICtrlCreateCheckbox($LngCh2, 10, 30, 240, 20)
  25. GUICtrlSetOnEvent(-1, "_Checkbox2Click")
  26. $iCheckbox3 = GUICtrlCreateCheckbox($LngCh3, 10, 50, 240, 20)
  27. GUICtrlSetOnEvent(-1, "_Checkbox3Click")
  28. GUICtrlSetState(-1, 1)
  29. $sList = _GetDrv()
  30. $iCombo1 = GUICtrlCreateCombo("", 20, 78, 91, -1, 0x3)
  31. GUICtrlSetFont(-1, -1, -1, 0, "Courier New")
  32. GUICtrlSendMsg(-1, 0x160, 370, 0)
  33. GUICtrlSetData(-1, $sList, StringLeft($sList, StringInStr($sList & $sp, $sp) - 1))
  34. $iButton1 = GUICtrlCreateButton($LngBtn, 135, 75, 90, 32)
  35. GUICtrlSetOnEvent(-1, "_Button1Click")
  36. GUICtrlSetState($iButton1, 256)
  37. GUISetState()
  38.  
  39. While 1
  40.     Sleep(10000)
  41. WEnd
  42.  
  43. Func _Checkbox2Click()
  44.     GUICtrlSetState($iCheckbox1, 1)
  45. EndFunc
  46.  
  47. Func _Checkbox3Click()
  48.     GUICtrlSetState($iCheckbox1, 1)
  49. EndFunc
  50.  
  51. Func _Form1Close()
  52.     Exit
  53. EndFunc
  54.  
  55. Func _GetDrv()
  56.     Local $sInfo = _ComboListDrive('Fixed')
  57.     $sInfo &= _ComboListDrive('Removable')
  58.     Return StringTrimLeft($sInfo, 1)
  59. EndFunc
  60.  
  61. Func _Button1Click()
  62.     Local $sDisk = StringLeft(GUICtrlRead($iCombo1), 2)
  63.     If StringRight($sDisk, 1) = ":" Then
  64.         GUICtrlSetState($iButton1, 128)
  65.         Local $sArgs = $sDisk
  66.         If GUICtrlRead($iCheckbox1) = 1 Then $sArgs &= " /f"
  67.         If GUICtrlRead($iCheckbox2) = 1 Then $sArgs &= " /r"
  68.         If GUICtrlRead($iCheckbox3) = 1 Then $sArgs &= " /x"
  69.         RunWait(@ComSpec & ' /c (Title Check Disk & @Echo off & Color 1e & cls & chkdsk.exe ' & $sArgs & ' & set /p Ok=^>^>)')
  70.         GUICtrlSetState($iButton1, 64)
  71.     EndIf
  72. EndFunc
  73.  
  74. Func _ComboListDrive($Type)
  75.     Local $aDrive = DriveGetDrive($Type), $list = '', $sString, $sLabel
  76.     If @error Then Return ''
  77.     If $Type = 'Removable' Then $Type = 'Rem'
  78.     For $i = 1 To $aDrive[0]
  79.         If $aDrive[$i] = 'A:' Then ContinueLoop
  80.         $sLabel = DriveGetLabel($aDrive[$i])
  81.         If StringLen($sLabel) > 15 Then $sLabel = StringLeft($sLabel, 12) & '...'
  82.         $sString = StringFormat("%-2s %-5s %-15s %-5s ", StringUpper($aDrive[$i]), $Type, $sLabel, _
  83.                 DriveGetFileSystem($aDrive[$i])) & _GetSize(DriveSpaceTotal($aDrive[$i])) & ' Gb'
  84.         $list &= $sp & $sString
  85.     Next
  86.     Return $list
  87. EndFunc
  88.  
  89. Func _GetSize($s)
  90.     $s = StringFormat('%.03f', $s / 1024)
  91.     If StringLen($s) > 7 Then $s = StringRegExpReplace(StringTrimRight($s, 4), '(\A\d{1,3}(?=(\d{3})+\z)|\d{3}(?=\d))', '\1 ') & StringRight($s, 4)
  92.     Return StringFormat('%9s', $s) ; 9 терабайт
  93. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement