Sign in to follow this  
Followers 0
Qual-IT London

drive get

13 posts in this topic

interesting

filegetfolder allows me to get a folder by browsing but is there a simple way of doing a "drivegetfolder" to select the current drives on the system?

so it just shows a pulldown menu perhaps with A -> F or whatever the user has.

Or do I have to make it myself by getting the current driveinfo and using a list ?

Share this post


Link to post
Share on other sites



interesting

filegetfolder allows me to get a folder by browsing but is there a simple way of doing a "drivegetfolder" to select the current drives on the system?

so it just shows a pulldown menu perhaps with A -> F or whatever the user has.

Or do I have to make it myself by getting the current driveinfo and using a list ?

Use DriveGetDrive and make a List or ComboBox etc....


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Use DriveGetDrive and make a List or ComboBox etc....

Thought so

This works just fine for anyone else who may need something similar

#include <GuiConstants.au3>

#include <GuiCombo.au3>

;Opt('MustDeclareVars',1)

Dim $Combo

GuiCreate("Select Drive", 392, 254)

$Combo = GuiCtrlCreateCombo("", 70, 10, 270, 21)

GuiSetState()

$var = DriveGetDrive( "all" )

If NOT @error Then

For $i = 1 to $var[0]

GUICtrlSetData($Combo,$var[$i])

; MsgBox(4096,"Drive " & $i, $var[$i])

Next

EndIf

while 1

wend

Share this post


Link to post
Share on other sites

if your using beta here's something else you might want to look at

#include <GUIConstants.au3>
#include <GuiList.au3>

Opt ('MustDeclareVars', 1)

Dim $a_check[9], $msg, $ret, $s_attr
Dim $input, $group, $a_attr, $listbox, $button

GUICreate("ListBox Drive Demo", 400, 250, -1, -1)
GUICtrlCreateLabel("Enter files to find", 25, 15)
$input = GUICtrlCreateInput("", 125, 10, 180, 25)
$group = GUICtrlCreateGroup("Atrributes", 10, 40, -1, 180)
$a_attr = StringSplit("A,D,H,RO,RW,S,E,Drives", ",")
$a_check[0] = 8
$a_check[1] = GUICtrlCreateCheckbox("Archive", 15, 55, 170, 20)
$a_check[2] = GUICtrlCreateCheckbox("Directory", 15, 75, 170, 20)
$a_check[3] = GUICtrlCreateCheckbox("Hidden", 15, 95, 170, 20)
$a_check[4] = GUICtrlCreateCheckbox("Read-Only", 15, 115, 170, 20)
$a_check[5] = GUICtrlCreateCheckbox("Read-Write", 15, 135, 95, 20)
$a_check[6] = GUICtrlCreateCheckbox("System", 15, 155, 170, 20)
$a_check[7] = GUICtrlCreateCheckbox("Exclusive", 15, 175, 170, 20)
$a_check[8] = GUICtrlCreateCheckbox("Drives", 15, 195, 170, 20)
GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group

$listbox = GUICtrlCreateList("", 240, 40, 120, 120)
$button = GUICtrlCreateButton("Get Names", 240, 160, 120, 40)

GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $button
            _GUICtrlListClear ($listbox)
            $ret = _GUICtrlListAddDir ($listbox, $s_attr, GUICtrlRead($input))
            If ($ret < 0) Then
                If ($ret == $LB_ERRATTRIBUTE) Then
                    MsgBox(16, "Error", "Invalid Attribute sent to _GUICtrlListAddDir")
                ElseIf ($ret == $LB_ERRSPACE) Then
                    MsgBox(16, "Error", "insufficient space to store the new strings from calling _GUICtrlListAddDir")
                ElseIf ($ret == $LB_ERRREQUIRED) Then
                    MsgBox(16, "Error", "Argument required for file search in call to _GUICtrlListAddDir")
                ElseIf ($ret == $LB_ERR) Then
                    MsgBox(16, "Error", "Unknown error from _GUICtrlListAddDir" & @CRLF & "Possibly no files/folders found")
                EndIf
            EndIf
        Case Else
            $s_attr = ""
            For $i = 1 To $a_check[0]
                If (GUICtrlRead($a_check[$i]) == $GUI_CHECKED) Then
                    If (StringLen($s_attr) > 0) Then
                        $s_attr &= "," & $a_attr[$i]
                    Else
                        $s_attr = $a_attr[$i]
                    EndIf
                EndIf
            Next
    EndSelect
WEnd

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

also there's the combo box udf

#include <GuiConstants.au3>
#include <GuiCombo.au3>

Opt('MustDeclareVars',1)

Dim $Combo,$ret,$Btn_Exit,$Status,$msg,$allocated

GuiCreate("ComboBox Add Dir", 392, 254)

$Combo = GuiCtrlCreateCombo("", 70, 10, 270, 100,$CBS_SIMPLE)
$allocated = _GUICtrlComboInitStorage($Combo, 26, 50)
$ret = _GUICtrlComboAddDir($Combo,"drives")
$Btn_Exit = GuiCtrlCreateButton("Exit", 150, 180, 90, 30)
$Status = GUICtrlCreateLabel("",0,234,392,20,BitOR($SS_SUNKEN,$SS_CENTER))
GUICtrlSetData($Status,"Pre-Allocated Memory For: " & $allocated & " Items, Drives Added To ComboBox: " & _GUICtrlComboGetCount($Combo))
GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
            ExitLoop
    EndSelect
WEnd
Exit

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

I need to let the user choose a drive on the system that is not present (to create a ramdrive)

I have come up with this that seems to work ok (bear in mind im not a real programmer!) :o

#include <GuiConstants.au3>

#include <GuiCombo.au3>

;Opt('MustDeclareVars',1)

Dim $combo

GuiCreate("Select Drive", 392, 254)

$Combo = GuiCtrlCreateCombo("", 70, 10, 270, 21)

GuiSetState()

$stat = DriveStatus ( "z:" )

if $stat = "INVALID" Then GUICtrlSetData($Combo,"z:")

$stat = DriveStatus ( "y:" )

if $stat = "INVALID" Then GUICtrlSetData($Combo,"y:")

$stat = DriveStatus ( "x:" )

if $stat = "INVALID" Then GUICtrlSetData($Combo,"x:")

$stat = DriveStatus ( "w:" )

if $stat = "INVALID" Then GUICtrlSetData($Combo,"w:")

$stat = DriveStatus ( "v:" )

if $stat = "INVALID" Then GUICtrlSetData($Combo,"v:")

$stat = DriveStatus ( "u:" )

if $stat = "INVALID" Then GUICtrlSetData($Combo,"u:")

$stat = DriveStatus ( "t:" )

if $stat = "INVALID" Then GUICtrlSetData($Combo,"t:")

$stat = DriveStatus ( "s:" )

if $stat = "INVALID" Then GUICtrlSetData($Combo,"s:")

$stat = DriveStatus ( "r:" )

if $stat = "INVALID" Then GUICtrlSetData($Combo,"r:")

$stat = DriveStatus ( "q:" )

if $stat = "INVALID" Then GUICtrlSetData($Combo,"q:")

$stat = DriveStatus ( "p:" )

if $stat = "INVALID" Then GUICtrlSetData($Combo,"p:")

$stat = DriveStatus ( "o:" )

if $stat = "INVALID" Then GUICtrlSetData($Combo,"o:")

$stat = DriveStatus ( "n:" )

if $stat = "INVALID" Then GUICtrlSetData($Combo,"n:")

$stat = DriveStatus ( "m:" )

if $stat = "INVALID" Then GUICtrlSetData($Combo,"m:")

$stat = DriveStatus ( "l:" )

if $stat = "INVALID" Then GUICtrlSetData($Combo,"l:")

$stat = DriveStatus ( "k:" )

if $stat = "INVALID" Then GUICtrlSetData($Combo,"k:")

$stat = DriveStatus ( "j:" )

if $stat = "INVALID" Then GUICtrlSetData($Combo,"j:")

$stat = DriveStatus ( "i:" )

if $stat = "INVALID" Then GUICtrlSetData($Combo,"i:")

$stat = DriveStatus ( "h:" )

if $stat = "INVALID" Then GUICtrlSetData($Combo,"h:")

$stat = DriveStatus ( "g:" )

if $stat = "INVALID" Then GUICtrlSetData($Combo,"g:")

$stat = DriveStatus ( "f:" )

if $stat = "INVALID" Then GUICtrlSetData($Combo,"f:")

$stat = DriveStatus ( "e:" )

if $stat = "INVALID" Then GUICtrlSetData($Combo,"e:")

$stat = DriveStatus ( "d:" )

if $stat = "INVALID" Then GUICtrlSetData($Combo,"d:")

;_GUICtrlComboShowDropDown($Combo,1)

;GUICtrlSetData ( -1, $combo , $var[0] )

while 1

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

Exitloop

EndSelect

wend

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Shorter code:

#include <GuiConstants.au3>
#include <GuiCombo.au3>

;Opt('MustDeclareVars',1)

Dim $combo

GuiCreate("Select Drive", 392, 254)
$Combo = GuiCtrlCreateCombo("", 70, 10, 270, 21)
GuiSetState()
For $i = Asc('a') to Asc('z')
   $stat = DriveStatus (Chr($i)&":")
   if $stat <> "INVALID" Then GUICtrlSetData($Combo,Chr($i)&":")
Next

while 1

$msg = GUIGetMsg()
Select

Case $msg = $GUI_EVENT_CLOSE
Exitloop
EndSelect
wend

#)

EDIT: DriceStatus -> DriveStatus

Edited by nfwu

Share this post


Link to post
Share on other sites

... Just FYI, to make life a bit easier in the future:

When doing things like:

$stat = DriveStatus ( "z:" )
if $stat = "INVALID" Then GUICtrlSetData($Combo,"z:")
$stat = DriveStatus ( "y:" )
if $stat = "INVALID" Then GUICtrlSetData($Combo,"y:")
$stat = DriveStatus ( "x:" )
if $stat = "INVALID" Then GUICtrlSetData($Combo,"x:")
$stat = DriveStatus ( "w:" )
if $stat = "INVALID" Then GUICtrlSetData($Combo,"w:")
$stat = DriveStatus ( "v:" )
if $stat = "INVALID" Then GUICtrlSetData($Combo,"v:")
$stat = DriveStatus ( "u:" )
if $stat = "INVALID" Then GUICtrlSetData($Combo,"u:")
$stat = DriveStatus ( "t:" )
if $stat = "INVALID" Then GUICtrlSetData($Combo,"t:")
$stat = DriveStatus ( "s:" )
if $stat = "INVALID" Then GUICtrlSetData($Combo,"s:")
$stat = DriveStatus ( "r:" )
if $stat = "INVALID" Then GUICtrlSetData($Combo,"r:")
$stat = DriveStatus ( "q:" )
if $stat = "INVALID" Then GUICtrlSetData($Combo,"q:")
$stat = DriveStatus ( "p:" )
if $stat = "INVALID" Then GUICtrlSetData($Combo,"p:")
$stat = DriveStatus ( "o:" )
if $stat = "INVALID" Then GUICtrlSetData($Combo,"o:")
$stat = DriveStatus ( "n:" )
if $stat = "INVALID" Then GUICtrlSetData($Combo,"n:")
$stat = DriveStatus ( "m:" )
if $stat = "INVALID" Then GUICtrlSetData($Combo,"m:")
$stat = DriveStatus ( "l:" )
if $stat = "INVALID" Then GUICtrlSetData($Combo,"l:")
$stat = DriveStatus ( "k:" )
if $stat = "INVALID" Then GUICtrlSetData($Combo,"k:")
$stat = DriveStatus ( "j:" )
if $stat = "INVALID" Then GUICtrlSetData($Combo,"j:")
$stat = DriveStatus ( "i:" )
if $stat = "INVALID" Then GUICtrlSetData($Combo,"i:")
$stat = DriveStatus ( "h:" )
if $stat = "INVALID" Then GUICtrlSetData($Combo,"h:")
$stat = DriveStatus ( "g:" )
if $stat = "INVALID" Then GUICtrlSetData($Combo,"g:")
$stat = DriveStatus ( "f:" )
if $stat = "INVALID" Then GUICtrlSetData($Combo,"f:")
$stat = DriveStatus ( "e:" )
if $stat = "INVALID" Then GUICtrlSetData($Combo,"e:")
$stat = DriveStatus ( "d:" )
if $stat = "INVALID" Then GUICtrlSetData($Combo,"d:")
You could always use a For/Next Loop to make life a bit easier
For $i = 90 To 68 Step - 1
    Local $stat = DriveStatus(Chr(68) & ':')
    If $stat = "INVALID" Then GUICtrlSetData($Combo, Chr(68) & ':')
Next

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Im smoked out :o

what the hell is that!!!

For $i = 90 To 68 Step - 1!? 90-68 where did those numbers come from?!

Share this post


Link to post
Share on other sites

Im smoked out :o

what the hell is that!!!

For $i = 90 To 68 Step - 1!? 90-68 where did those numbers come from?!

ascii values for the letters.... do a search in help file for ascii to see the whole list


1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

ascii values for the letters.... do a search in help file for ascii to see the whole list

who wants to finish me off :o!

$Combo = GuiCtrlCreateCombo("", 50, 110, 270, 21)

GuiSetState()

$stat = DriveStatus ( "z:" )

if $stat = "INVALID" Then GUICtrlSetData($Combo,"z:")

$stat = DriveStatus ( "y:" )

if $stat = "INVALID" Then GUICtrlSetData($Combo,"y:")

$stat = DriveStatus ( "x:" )

if $stat = "INVALID" Then GUICtrlSetData($Combo,"x:")

I have the combo box on the screen, its empty, if i pull it down it contains Z, X and Y

perfect!

But i want Z to be already selected in the combo box or Y if Z isn't in the list

Share this post


Link to post
Share on other sites

if your wanting the 1st selection

_GUICtrlComboSetCurSel($Combo,0)

or the last

_GUICtrlComboSetCurSel($Combo,_GUICtrlComboGetCount($Combo) - 1)

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

#include <GuiConstants.au3>
#include <GuiCombo.au3>

;Opt('MustDeclareVars',1)

Dim $Combo

GUICreate("Select Drive", 392, 254)
$Combo = GUICtrlCreateCombo("", 70, 10, 270, 21)

For $i = 90 To 68 Step - 1
    Local $stat = DriveStatus(Chr($i) & ':')
    If $stat = "INVALID" Then GUICtrlSetData($Combo, Chr($i) & ':')
Next
_GUICtrlComboSetCurSel ($Combo, 0)
GUISetState()

While 1
    
    $msg = GUIGetMsg()
    Select
        
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
    EndSelect
WEnd

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

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