Anyone wanting to use the windows defrag icon it can be found in shell.32 as icon_81.ico
Please post any bugs you encounter.
/Revision
I've added the actual progress values rounded to the nearest whole number as they go by.
/Revision
New formula on progress bar is more accurate, determined by actual sizes of the drives, I tried to get it to sub-calculate values for each drive based on the time it takes to defrag x.x MB and the total size of the drive but it was more difficult than I expected, perhaps later I will add an Estimated Time Remaining: counter as well.
HotKeySet( "{ESC}", "gotoExit" ) $var = DriveGetDrive( "FIXED" ) If NOT @error Then $totalspace = 0 $totalfree = 0 For $i = 1 to $var[0] $free = DriveSpaceFree( $var[$i] ) $total = DriveSpaceTotal( $var[$i] ) $totalfree = $Free + $totalfree $totalspace = $Total + $totalspace Next $totalused = $totalspace - $totalfree ProgressOn ( "AutoDefrag v0.4", "", "0%", -1, -1, 16 ) WinSetOnTop ( "AutoDefrag", "", 0 ) $usedCur = 0 For $i = 1 to $var[0] If $i = 1 Then $CurrPer = 0 Else $used = ( DriveSpaceTotal( $var[$i-1] ) - DriveSpaceFree( $var[$i-1] ) ) $usedCur = $used + $usedCur $currPer = ( $usedCur * 100 ) / $totalused EndIf ProgressSet( $currPer, Round( $currPer, 0 ) & "%", "Defragmenting " & $var[$i] ) RunWait ( @ComSpec & " /c" & 'DEFRAG ' & $var[$i], "", @SW_HIDE ) Next ProgressSet ( 95, "95%", 'Processing Idle Tasks' ) RunWait ( @WindowsDir & '\System32\rundll32.exe advapi32.dll,ProcessIdleTasks' ) ProgressSet ( 100 , "Done", "Complete" ) EndIf Exit Func gotoExit() ProgressOff() Exit EndFunc
Edited by chaos945, 14 August 2004 - 06:54 PM.






