myk3 Posted September 13, 2011 Share Posted September 13, 2011 I can not figure this out for the life of me.. I know it is simple but I just need fresh eyes on it i think.. I am pulling the fixed disk using $var = DriveGetDrive( "FIXED" ) I am trying to add a combo box with each item in the array into it.. but also add a new combo box for each item in the array then add the items from the array into the combo box.. so for example my array has "C:|D:|Z:" i should have 3 combo boxes with C: D: and Z: as options here is what i am using.. but if there is more than 4 fixed drives (or partitions) then it will stop at 4. $var = DriveGetDrive( "FIXED" ) If NOT @error Then For $i = 1 to $var[0] $Drive = GUICtrlCreateCombo("", 242, 175, 145, 25) GuiCtrlSetData($Drive, "|" & _ArrayToString($var, "|", 1)) Next if ubound($var)-1 > 1 then For $i = 1 to $var[0] $Drive1 = GUICtrlCreateCombo("", 242, 200, 145, 25) GuiCtrlSetData($Drive1, "|" & _ArrayToString($var, "|", 1)) Next endif if ubound($var)-1 > 2 then For $i = 1 to $var[0] $Drive1 = GUICtrlCreateCombo("", 242, 225, 145, 25) GuiCtrlSetData($Drive1, "|" & _ArrayToString($var, "|", 1)) Next endif if ubound($var)-1 > 3 then For $i = 1 to $var[0] $Drive1 = GUICtrlCreateCombo("", 242, 250, 145, 25) GuiCtrlSetData($Drive1, "|" & _ArrayToString($var, "|", 1)) Next endif EndIf Link to comment Share on other sites More sharing options...
sleepydvdr Posted September 14, 2011 Share Posted September 14, 2011 I just wrote a little script using DriveGetDrive and discovered that using "Fixed" did not work for me. Using "All" worked perfectly. So, my suggestion is to change Fixed to All. Here's my script (it returns an array of all your drive letters): #include <Array.au3> $driveList = DriveGetDrive("All") Dim $list[$driveList[0]] Global $i = 0 For $j = 65 To 90 Step 1 $tempDriveLetter = Chr($j) DriveGetType($tempDriveLetter & ":\") If NOT @error Then $list[$i] = $tempDriveLetter $i += 1 EndIf Next _ArrayDisplay($list) #include <ByteMe.au3> Link to comment Share on other sites More sharing options...
myk3 Posted September 14, 2011 Author Share Posted September 14, 2011 (edited) Well you go me started on the right path.. $drives = DriveGetDrive("All") returns an arrary of all the drive letters on your system $drives = DriveGetDrive("FIXED") returns an arrary of all the fixed disk drive letters on your system (C: for most cases) Here is what i am using and it does what I need it to do.. $driveList = DriveGetDrive("all") $loc = 175 $inc = 0 Global $i = 0 For $j = UBound($driveList)-1 to 1 step -1 If NOT @error Then for $p = UBound($driveList)-1 to 1 step -1 $Drive[$p] = GUICtrlCreateCombo("", 242, $loc + $inc, 145, 25) GuiCtrlSetData($Drive[$p], "|" & _ArrayToString($driveList, "|", 1)) next $inc += 25 $i += 1 EndIf Next Thanks for the help.. Edited September 14, 2011 by myk3 Link to comment Share on other sites More sharing options...
Spiff59 Posted September 14, 2011 Share Posted September 14, 2011 (edited) You have me a little confused, DriveGetDrive("All") returns 5 drives on my PC, so I get five sets ($j) of five comboboxes ($p) stacked on top of each other, twenty-five comboboxes in all.. Your @error test probably needs to be right after the DriveGetDrive, rather than testing the result of a UBound() statement. You can dispense with the UBound() statements altogether as DriveGetDrive() already returns the drive count in element 0, and you probably only need to execute _ArrayToString() once? Maybe: Global $Drive[10] $aDriveList = DriveGetDrive("All") ; drives array If @error Then MsgBox(1,"","No drives found") Exit EndIf $sDriveList = _ArrayToString($driveList, "|", 1) ; drives string for $p = 1 to $driveList[0] $Drive[$p] = GUICtrlCreateCombo("", 242, 175 + $p * 25, 145, 25) GuiCtrlSetData($Drive[$p], "|" & $sDriveList) Next Edited September 14, 2011 by Spiff59 Link to comment Share on other sites More sharing options...
myk3 Posted September 14, 2011 Author Share Posted September 14, 2011 Yea i just saw the $j was running through and overwriting the comboboxes for me.. I changed it to this.. $driveList = DriveGetDrive("fixed") $loc = 175 $inc = 0 for $p = UBound($driveList)-1 to 1 step -1 $Drive[$p] = GUICtrlCreateCombo("", 242, $loc + $inc, 145, 25) GuiCtrlSetData($Drive[$p], "|" & _ArrayToString($driveList, "|", 1)) $inc += 25 next $inc = 0 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