wi1d Posted November 27, 2005 Share Posted November 27, 2005 (edited) I'm wanting to populate a combo box with drives that are available to map to. So I have to somehow minus all drives that are already in use. I've racked my brain and search the site and haven't come up with anything besides possible creating an array to list A: - Z: and then using DriveGetDrive() and to compare the two to find what drives are available. However I'm sure there has to be a better way and was wondering if anyone has a suggestion. Thanks. Edited November 27, 2005 by wi1d Link to comment Share on other sites More sharing options...
Developers Jos Posted November 27, 2005 Developers Share Posted November 27, 2005 (edited) Something like: Dim $AllDrives For $x = 1 to 26 $AllDrives = $AllDrives & "|" & chr(96+$x) & ":" Next $var = DriveGetDrive( "all" ) If NOT @error Then For $i = 1 to $var[0] $AllDrives = StringReplace($AllDrives,"|" & $var[$i],"") Next EndIf and use $AllDrives in your Combobox Edited November 27, 2005 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
CyberSlug Posted November 27, 2005 Share Posted November 27, 2005 (edited) @JdeB: That's hard to follow.... I'm pretty sure that DriveStatus will do what you want. The message box is included to help debug.... $debug = "Drive" & @TAB & "Status" & @TAB & @TAB & "GetType" & @TAB & "MapGet" & @LF $debug = $debug & "------" & @TAB & "-------" & @TAB & @TAB & "-------" & @TAB & "-------" $list = "" For $i = Asc("B") to Asc("Z") $drive = Chr($i) & ":" If DriveStatus($drive) = "INVALID" Then $list = $list & $drive & "|" $debug = $debug & @LF & $drive & @TAB & DriveStatus($drive) & @TAB & @TAB & DriveGetType($drive) & @TAB & DriveMapGet($drive) Next #include <GuiConstants.au3> GuiCreate("Example", -1, -1, 100, 100);change default posotion $combo = GuiCtrlCreateCombo("",50, 50, 100, 200, $CBS_DROPDOWNLIST) $defaultSelection = StringLeft($list,StringInStr($list,":"));the first drive letter $infoButton = GuiCtrlCreateButton("Debug", 200, 100, 100, 50) GuiCtrlSetData($combo, $list, $defaultSelection) GuiSetState(@SW_SHOW) While 1 $msg = GuiGetMsg() If $msg = $GUI_EVENT_CLOSE Then Exit If $msg = $infoButton Then MsgBox(4096,"For Debugging", $debug) WEnd Edit: Improved example. Edited November 27, 2005 by CyberSlug Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
wi1d Posted November 28, 2005 Author Share Posted November 28, 2005 Thanks for both examples. I really liked your use of Asc, Chr, w/ the loop. Great stuff, I wouldn't have thought of that. Thanks again. 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