#Region ;
#AutoIt3Wrapper_UseAnsi=y
#EndRegion ;
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <Constants.au3>
#include <StaticConstants.au3>
#include <Date.au3>
#include <File.au3>
GUICreate("Formater Ver 1.4", 633, 380, 193, 125)
Dim $xz, $a, $b, $zx, $Q, $F, $ff,$H, $M, $S,$aArray2, $z,$x
Local $add, $clear, $mylist, $Button1, $sf, $format
$myedit = GUICtrlCreateEdit("", 5, 32, 620, 200)
$Button1 = GUICtrlCreateButton("Start Format Disc", 380, 250, 245, 33, 0)
GUICtrlCreateGroup(" Choose Format Way ", 230, 250, 140, 100)
$Q = GUICtrlCreateRadio("Quick Format", 250, 280, 100, 20)
$F = GUICtrlCreateRadio("Full Format", 250, 300, 100, 20)
GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group
GUISetState()
$var = DriveGetDrive("REMOVABLE")
$xz = GUICtrlCreateCombo("Select The Disc", 20, 250, 200, 30)
For $i = 1 To $var[0]
GUICtrlSetData($xz, $var[$i])
Next
GUISetState(@SW_SHOW)
While 1
$Msg = GUIGetMsg()
Switch $Msg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$F111 = MsgBox(1 + 48, 'Attention', 'Are you sure you want to format this disc?')
Select
Case $F111 = 1
If BitAND(GUICtrlRead($Q), $GUI_CHECKED) Then $format = '/Q/'
If BitAND(GUICtrlRead($F), $GUI_CHECKED) Then $format = '/'
_test()
Case $F111 = 2
ContinueLoop
EndSelect
EndSwitch
WEnd
Func _test()
Local $foo, $line, $lines, $currentRead
$a = TimerInit()
$zx = GUICtrlRead($xz)
$foo = Run(@ComSpec & " /c " & 'Format ' & $zx & '/FS:FAT32/V:Haha' & $format & 'X/Y', "", @SW_HIDE, $STDOUT_CHILD)
While 1
$line = StdoutRead($foo)
If @error Then ExitLoop
GUICtrlSetData($myedit, $line, -1)
FileWrite(@ScriptDir & "\1.txt", $line & @CRLF)
_FileReadToArray(@ScriptDir & "\1.txt", $aArray2)
For $x = 1 To $aArray2[0]
If $aArray2[$x] = "" Then
_FileWriteToLine(@ScriptDir & "\1.txt", $x - $z, '', 1)
$z += 1
EndIf
Next
WEnd
$b = TimerDiff($a)
$c = $b / 1000
_TicksToTime(Int($b), $H, $M, $S)
Msgbox(64,"Finish","This format cost you " & $H & ' Hours ' & $M & ' Minutes ' & $S & ' Seconds')
EndFunc;==>_test