waardd Posted May 9, 2012 Share Posted May 9, 2012 I have a function to calculate diskusage and set it on a progressbar. $PercC = GUICtrlCreateLabel("",20,55,125,15,-1,-1) $BarC = GUICtrlCreateProgress(20,40,200,15,-1,-1) Func _diskC() $FileSys = DriveGetFileSystem( "c:\" ) $SizeFree = (DriveSpaceFree( "c:\" )/1024) $SizeTotal = (DriveSpaceTotal("c:\")/1024) $SizeUsed = $SizeTotal - $SizeFree $PercUsed = ($SizeUsed/$SizeTotal)*100 $PercRounded2 = StringFormat("%.2f", $PercUsed)&"% in use op C:" GuiCtrlSetData($BarC,$PercUsed) GuiCtrlSetData($PercC,$PercRounded2) EndFunc What i want is a automated routine to do this for al disks in a system independant of the configuration and show them al in on screen (kinda like explorer in windows) Link to comment Share on other sites More sharing options...
hannes08 Posted May 9, 2012 Share Posted May 9, 2012 Hi waardd, first you need to identify all hard drives in your system ... see function DriveGetDrive(). Now you know how many drives you have and what their drive letter is. So you can 1. determine how big your GUI has to be and 2. how may labels and progress bars you'll need. Just run your function with different parameters. Create an array for your label/percentage gui objects. Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler] Link to comment Share on other sites More sharing options...
waardd Posted May 9, 2012 Author Share Posted May 9, 2012 (edited) Tnx Hannes08I found the functions and combined it with my script to look something like this #include <GUIConstantsEx.au3> $Form1_1 = GUICreate("DiscInfo", 615, 350, 192, 124) $var = DriveGetDrive( "all" ) If NOT @error Then For $i = 1 to $var[0] $FileSys = DriveGetFileSystem( $var[$i] ) $SizeFree = (DriveSpaceFree( $var[$i] )/1024) $SizeTotal = (DriveSpaceTotal($var[$i])/1024) $SizeUsed = $SizeTotal - $SizeFree $PercUsed = ($SizeUsed/$SizeTotal)*100 $PercRounded2 = StringFormat("%.2f", $PercUsed) if $PercRounded2 < 0 Then GUICtrlCreateLabel("Drive "&$var[$i]&" is unknown",10,$i*15, 190) Else GUICtrlCreateLabel("Drive "&$var[$i]&" uses "&$PercRounded2&" %",10,$i*15, 190) GUICtrlCreateProgress(200,$i*15,200,15,-1,-1) GuiCtrlSetData(-1,$PercUsed) EndIf Next EndIf GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEndThis is with help from example script for compinfo.au3 by JSThePatriot Edited May 9, 2012 by waardd Link to comment Share on other sites More sharing options...
hannes08 Posted May 9, 2012 Share Posted May 9, 2012 This is what I came up with: expandcollapse popup#include <GUIConstantsEx.au3> #include <ProgressConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $a_drives = DriveGetDrive("ALL") Global $a_guielements[$a_drives[0] + 1][2] $a_guielements[0][0] = $a_drives[0] * 2 Opt("GUIOnEventMode", 1) $Form1 = GUICreate("Form1", 300, 40 + 20 * $a_drives[0], -1, -1) GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close") for $i = 1 to $a_drives[0] $a_guielements[$i][0] = GUICtrlCreateLabel($a_drives[$i], 20, 20 * $i, 110, 17) $a_guielements[$i][1] = GUICtrlCreateProgress(130, 20 * $i, 150, 17) _disk($a_drives[$i], $a_guielements[$i][1], $a_guielements[$i][0]) Next GUISetState(@SW_SHOW) While 1 Sleep(100) WEnd Func Form1Close() Exit EndFunc Func _disk($letter, $progress, $label) $FileSys = DriveGetFileSystem( $letter ) $SizeFree = (DriveSpaceFree( $letter )/1024) $SizeTotal = (DriveSpaceTotal($letter)/1024) If $SizeTotal > 0 Then $SizeUsed = $SizeTotal - $SizeFree $PercUsed = ($SizeUsed/$SizeTotal)*100 $PercRounded2 = StringFormat("%.2f", $PercUsed)&"% in use on " & StringUpper($letter) GuiCtrlSetData($progress,$PercUsed) GuiCtrlSetData($label,$PercRounded2) Else GuiCtrlSetData($progress, 0) GuiCtrlSetData($label,StringUpper($letter) & " seems to be empty!") EndIf EndFunc Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler] Link to comment Share on other sites More sharing options...
James Posted May 9, 2012 Share Posted May 9, 2012 Maybe DiskManager would be of use to you. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now