[Ex] Script qui calcule l'espace disk C:\ et G:\

Partagez vos scripts, et vos applications AutoIt.
Règles du forum
.
Répondre
liberte75
Niveau 4
Niveau 4
Messages : 51
Enregistré le : mar. 29 janv. 2013 14:39
Status : Hors ligne

[Ex] Script qui calcule l'espace disk C:\ et G:\

#1

Message par liberte75 »

Bonjour tout le monde
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
Avatar du membre
mikell
Spammer !
Spammer !
Messages : 6292
Enregistré le : dim. 29 mai 2011 17:32
Localisation : Deep Cévennes
Status : Hors ligne

Re: [Ex] Script qui calcule l'espace disk C:\ et G:\

#2

Message par mikell »

Faudrait tester ton type d'affichage avec la fonction que j'utilise dans ce script, là :
http://www.autoitscript.fr/forum/viewto ... f=6&t=9006
" L'échec est le fondement de la réussite. " (Lao-Tseu )
" Plus ça rate, plus on a de chances que ça marche " (les Shadoks )
Répondre