Sign in to follow this  
Followers 0
James

Multi Create

12 posts in this topic

Hey all,

I was wandering if anyone could help me.

I need to find the amount of fixed drives, then create as many progress as there are drives. I then need to add a label above the progress with the drive name and letter.

Any ideas?

I know it will need a For Next Loop but I am not sure how.

Thankyou,

James

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I suppose you could try something like this

#include <GUIConstants.au3>

$Drives=DriveGetDrive("ALL")

Dim $Labels[$Drives[0]+1]
Dim $Progress[$Drives[0]+1]
$Form1 = GUICreate("Form1", 225,20+ $Drives[0]*25, 195, 136)

For $i=1 To $Drives[0]
    $Labels[$i]=GUICtrlCreateLabel(StringUpper($Drives[$i]),24,$i*20)
    $Progress[$i] = GUICtrlCreateProgress(80, $i*20, 121, 17)
Next
GUISetState(@SW_SHOW)


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd
Edited by Nahuel

Share this post


Link to post
Share on other sites

haha, no problem! :P I just made a slight modification. If you have less than 2 drives it looked cut off :)

Share this post


Link to post
Share on other sites

Erm.. How would I go about setting each progress?

#include <GUIConstants.au3>

Global $Drives = DriveGetDrive("FIXED")
Dim $Labels[$Drives[0] + 1]
Dim $Progress[$Drives[0] + 1]

DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0)

$GUI = GUICreate("Drive Percentages", 225, $Drives[0] * 40, -1, -1)

For $i = 1 To $Drives[0]
    $Labels[$i] = GUICtrlCreateLabel(StringUpper($Drives[$i]), 24, $i * 20)
    $Progress[$i] = GUICtrlCreateProgress(80, $i * 20, 121, 17)
Next

Space()

GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Func Space()
    ; Space / Total * 100 = Percentage
    For $a = 1 To $Drives[0]
        $Space = DriveSpaceFree($Drives[$a])
        $Total = DriveSpaceTotal($Drives[$a])
        GuiCtrlSetData($Drives[$a], $Space[$a] / $Total[$a] * 100)
    Next
EndFunc

Sorry, I ma having a dumb day :)

Share this post


Link to post
Share on other sites

Done!

#include <GUIConstants.au3>

Global $Drives = DriveGetDrive("FIXED")
Dim $Labels[$Drives[0] + 1]
Dim $Progress[$Drives[0] + 1]

DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0)

$GUI = GUICreate("Drive Percentages", 225, $Drives[0] * 40, -1, -1)

For $i = 1 To $Drives[0]
    $Labels[$i] = GUICtrlCreateLabel(StringUpper($Drives[$i]), 24, $i * 20)
    $Progress[$i] = GUICtrlCreateProgress(45, $i * 20, 150, 17, 0x1)
    GUICtrlSetColor(-1, 0x00ff00)
    For $a = 1 to $Drives[0]
        $Space = DriveSpaceFree($Drives[$a])
        $Total = DriveSpaceTotal($Drives[$a])
        GuiCtrlSetData($Progress[$a], $Space / $Total * 100)
    Next
Next

GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Woop!

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Mmm, like this?

#include <GUIConstants.au3>

Global $Drives = DriveGetDrive("FIXED")
Dim $Labels[$Drives[0] + 1]
Dim $Progress[$Drives[0] + 1]

DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0)

$GUI = GUICreate("Drive Percentages", 225, $Drives[0] * 40, -1, -1)

For $i = 1 To $Drives[0]
    $Labels[$i] = GUICtrlCreateLabel(StringUpper($Drives[$i]), 24, $i * 20)
    $Progress[$i] = GUICtrlCreateProgress(80, $i * 20, 121, 17)
Next

Space()

GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Func Space()
    ; Space / Total * 100 = Percentage
    For $a = 1 To $Drives[0]
        $Space = DriveSpaceFree($Drives[$a])
        $Total = DriveSpaceTotal($Drives[$a])
        GuiCtrlSetData($Progress[$a], 100 - Int(($Space * 100)/ $Total))
         ;100 - Int(($Space * 100)/ $Total)-->Represent full percentage
         ;Int(($Space * 100)/ $Total)-->Represent free percentage
    Next
EndFunc

edit: Yeah. haha you had the variables messed up

Edited by Nahuel

Share this post


Link to post
Share on other sites

This seems pretty elementary for someone with 3300 posts. What gives JamesB?

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

This seems pretty elementary for someone with 3300 posts. What gives JamesB?

haha, that's what I thought too but he said he's having a dumb day :)

Edited by Nahuel

Share this post


Link to post
Share on other sites

Yeah, I haven't been with it for a while. I am really sorry folks, it's just I have been having a hard time. One of my friends passed away the other day. I have tried to keep myself occupied.

Sorry for your loss. If history has taught us anything, we should judge not by the quantity of ones posts, but by the content of their character.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0