Sign in to follow this  
Followers 0
Qual-IT London

folder browsing

5 posts in this topic

im trying to split my script into two screens, first screen to allow you to browse folders on the local machine

second screen to browse my network places

So far on both screens all I can do is use this command

$var = FileSelectFolder("Choose a folder !", "")

And then this code on each screen to stop people being able to actually select items i dont want them to select.

$drivetype = DriveGetType( $var )

if $drivetype = "Removable" Then

It works but it would be nicer if on screen one I could only show local drives

and on screen two only show my network places

Is this possible by parsing a parameter to fileselectfolder to tell it what to display as a choice??

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

maybe something like this:

#include <GUIConstants.au3>

$gui_select = GUICreate("Select Folder", 359, 367)

$lv_mapped = GUICtrlCreateListView("Mapped Drives", 32, 24, 121, 289)
$var = DriveGetDrive( "NETWORK")
If Not @error Then
    For $i = 1 To $var[0]
        GUICtrlCreateListViewItem($var[$i], $lv_mapped)
    Next
EndIf

$contextmenulv_mapped = GUICtrlCreateContextMenu($lv_mapped)
$contextmenulv_mappeditem = GUICtrlCreateMenuItem("Choose a folder !", $contextmenulv_mapped)

$lv_local = GUICtrlCreateListView("Local Drives", 192, 24, 121, 289)
$var = DriveGetDrive( "FIXED")
If Not @error Then
    For $i = 1 To $var[0]
        GUICtrlCreateListViewItem($var[$i], $lv_local)
    Next
EndIf

$contextmenulv_local = GUICtrlCreateContextMenu($lv_local)
$contextmenulv_localitem = GUICtrlCreateMenuItem("Choose a folder !", $contextmenulv_local)

$btn_ok = GUICtrlCreateButton("Ok", 136, 328, 65, 25, 0)

GUISetState(@SW_SHOW)
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE Or $msg = $btn_ok
            ExitLoop
        Case $msg = $contextmenulv_mappeditem
            If GUICtrlRead($lv_mapped) Then
                $var = FileSelectFolder("Choose a folder !", GUICtrlRead(GUICtrlRead($lv_mapped)) & "\")
            EndIf
        Case $msg = $contextmenulv_localitem
            If GUICtrlRead($lv_local) Then
                $var = FileSelectFolder("Choose a folder !", GUICtrlRead(GUICtrlRead($lv_local)) & "\")
            EndIf
        Case Else
        ;;;;;;;
    EndSelect
WEnd
Exit
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

not really, more just like having the folder browse box appear but minus any network locations

and vice versa being able to bring up the folder browse showing only Fixed type

if this isnt possible easily i will just stay with the restrictions that throw up a message if the wrong type of drive is selected.

one thing you may be able to help quickly with,

im using this code to take $var which is \\nick\share\folder1\test\playtime

to strip it down to this \\nick\share

only problem is it strips it to this \\nick\share\

can i get this to strip the last "\" as well?

$STR = StringSplit($var, "\")

$var = StringTrimRight($var, StringLen($STR[$STR[0]]))

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

not really, more just like having the folder browse box appear but minus any network locations

and vice versa being able to bring up the folder browse showing only Fixed type

if this isnt possible easily i will just stay with the restrictions that throw up a message if the wrong type of drive is selected.

one thing you may be able to help quickly with,

im using this code to take $var which is \\nick\share\folder1\test\playtime

to strip it down to this \\nick\share

only problem is it strips it to this \\nick\share\

can i get this to strip the last "\" as well?

$STR = StringSplit($var, "\")

$var = StringTrimRight($var, StringLen($STR[$STR[0]]))

if your only wanting the first folder after the share then something like

$var = StringSplit(StringTrimLeft("\\nick\share\folder1\test\playtime",2),"\")
$var = "\\" & $var[1] & "\" & $var[2]
MsgBox(0,"var",$var)
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

if your only wanting the first folder after the share then something like

$var = StringSplit(StringTrimLeft("\\nick\share\folder1\test\playtime",2),"\")
$var = "\\" & $var[1] & "\" & $var[2]
MsgBox(0,"var",$var)
ahh! I seeee

Thank ! You !

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