Jump to content

Multi Create


James
 Share

Recommended Posts

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

Link to comment
Share on other sites

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
Link to comment
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 :)

Link to comment
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!

Link to comment
Share on other sites

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
Link to comment
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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...