voici un script qui calcule l'espace disk utilisé pour un lecteur C:\ et G:\, puis affiche les resulats dans une barre progressif, ainsi que le pourcentage.
Peut etre un jour il sera utile pour quelqu'un!!!!!!
Code : Tout sélectionner
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=g:\logiciel\autoit\autoit_menu\form6.kxf
$Form1_1 = GUICreate("Form1", 625, 468, 438, 162)
$Progress_C = GUICtrlCreateProgress(140, 264, 417, 33)
$Progress_G = GUICtrlCreateProgress(140, 320, 417, 33)
$Group1 = GUICtrlCreateGroup("", 0, 384, 609, 100)
$Button1 = GUICtrlCreateButton("Cancel", 504, 408, 73, 25)
$Button2 = GUICtrlCreateButton("Get space >", 424, 408, 65, 30)
;$Button3 = GUICtrlCreateButton("< Back", 336, 408, 65, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("", 0, 0, 585, 89)
$Label1 = GUICtrlCreateLabel("Getting space of disk", 24, 16, 200, 20)
GUICtrlSetFont(-1, 11, 800, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Label2_1 = GUICtrlCreateLabel("Used space on Disk C:\", 20, 275, 120, 100)
$Label2_2 = GUICtrlCreateLabel("Used space on Disk G:\", 20,325, 120, 100)
$Label2_3 = GUICtrlCreateLabel("", 570, 275, 44, 20)
$Label2_4 = GUICtrlCreateLabel("", 570, 325, 44, 20)
$Label2 = GUICtrlCreateLabel("Status:", 128, 200, 44, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label6 = GUICtrlCreateLabel("", 128, 224, 42, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x008080)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Global $GB = "1000"
Global $sPer
While 1
$nMsg = GUIGetMsg()
Select
Case $nMsg = $GUI_EVENT_CLOSE
Exit
Case $nMsg = $Button2
_get_space()
Case $nMsg = $Button1
Exit
EndSelect
WEnd
Func _get_space()
$Total_perc = "100"
$Total_C = DriveSpaceTotal( "c:\" )
$Free_C = DriveSpaceFree( "c:\" )
$Used_C = $Total_C - $Free_C
$total_C_int_Mb = StringFormat ("%.0f",$Total_C)
$free_C_int_Mb = StringFormat ("%.0f",$Free_C)
$Used_C_int_Mb = StringFormat ("%.0f",$Used_C)
$total_C_int_Gb = $total_C_int_Mb/$GB
$free_C_int_Gb = $free_C_int_Mb/$GB
$Used_C_int_Gb = $used_C_int_Mb/$GB
$free_perc_C = $free_C_int_Gb*($Total_perc/$total_C_int_Gb)
$used_perc_C = $Used_C_int_Gb*($Total_perc/$total_C_int_Gb)
$used_perc_C = StringFormat ("%.0f",$used_perc_C )
$Total_G = DriveSpaceTotal( "G:\" )
$Free_G = DriveSpaceFree( "G:\" )
$Used_G = $Total_G - $Free_G
$total_G_int_Mb = StringFormat ("%.0f",$Total_G)
$free_G_int_Mb = StringFormat ("%.0f",$Free_G)
$Used_G_int_Mb = StringFormat ("%.0f",$Used_G)
$total_G_int_Gb = $total_G_int_Mb/$GB
$free_G_int_Gb = $free_G_int_Mb/$GB
$Used_G_int_Gb = $used_G_int_Mb/$GB
$free_perc_G = $free_G_int_Gb*($Total_perc/$total_G_int_Gb)
$used_perc_G = $Used_G_int_Gb*($Total_perc/$total_G_int_Gb)
$used_perc_G = StringFormat ("%.0f",$used_perc_G )
GUICtrlSetData($Progress_C, $used_perc_C)
;GUICtrlSetColor(
GUICtrlSetData($Progress_G, $used_perc_G)
GUICtrlSetData($Label2_3,$used_perc_C & " %")
GUICtrlSetData($Label2_4,$used_perc_G&" %")
EndFunc