Jump to content

Select folder


Recommended Posts

Hello to all,

search in forum with out luck, so i post incomplete script to help understand my request.

Have small GUI that give user the way to select local folder:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

;////////////////////////////////////////////////////////////////////
;//   GUI
;////////////////////////////////////////////////////////////////////
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("FTP Downloader", 552, 183, 21, 165)
$u = GUICtrlCreateInput("pippo", 8, 32, 105, 21)
$p = GUICtrlCreateInput("pippo", 120, 32, 105, 21)
$s = GUICtrlCreateInput("127.0.0.1", 232, 32, 145, 21)
$r = GUICtrlCreateInput("/local/goofy/", 384, 32, 153, 21)
$l = GUICtrlCreateInput("c:\", 8, 88, 369, 21)
$Label1 = GUICtrlCreateLabel("Login", 16, 8, 30, 17)
$Label2 = GUICtrlCreateLabel("Password", 128, 8, 50, 17)
$Label3 = GUICtrlCreateLabel("Ftp IP", 240, 8, 32, 17)
$Label4 = GUICtrlCreateLabel("Remote Directory", 384, 8, 86, 17)
$Label5 = GUICtrlCreateLabel("Local Directory", 8, 67, 104, 17)
$Button4 = GUICtrlCreateButton("select folder", 386, 88, 115, 25)
$Button3 = GUICtrlCreateButton("ESCI", 388, 136, 115, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
    
;////////////////////////////////////////////////////////////////////
;//   MAIN
;////////////////////////////////////////////////////////////////////
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button4
            _select_folder()
    EndSwitch
WEnd

;////////////////////////////////////////////////////////////////////
;//   FUNCs
;////////////////////////////////////////////////////////////////////

FUNC _select_folder()
    $sDir = FileSelectFolder("Select FTP folder", "", 0, @ScriptDir)
    If StringRight($sDir, 1) <> "\" Then $sDir &= "\"

    If $sDir = "\" Then
        ToolTip("user abort",0,0)
        Sleep(500)
        ToolTip("",0,0)
    Elseif $sDir <> "\" Then
;<------------------------------------------------- insert some code here please !
    
    EndIf

EndFunc

After selection want to update value in GUI:

$l = GUICtrlCreateInput("c:\", 8, 88, 369, 21)

replacing "c:\" with new value selected.

Hope question is clear, please help.

thank you all,

m.

Link to comment
Share on other sites

It's so easy:)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

;////////////////////////////////////////////////////////////////////
;//   GUI
;////////////////////////////////////////////////////////////////////
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("FTP Downloader", 552, 183, 21, 165)
$u = GUICtrlCreateInput("pippo", 8, 32, 105, 21)
$p = GUICtrlCreateInput("pippo", 120, 32, 105, 21)
$s = GUICtrlCreateInput("127.0.0.1", 232, 32, 145, 21)
$r = GUICtrlCreateInput("/local/goofy/", 384, 32, 153, 21)
$l = GUICtrlCreateInput("c:\", 8, 88, 369, 21)
$Label1 = GUICtrlCreateLabel("Login", 16, 8, 30, 17)
$Label2 = GUICtrlCreateLabel("Password", 128, 8, 50, 17)
$Label3 = GUICtrlCreateLabel("Ftp IP", 240, 8, 32, 17)
$Label4 = GUICtrlCreateLabel("Remote Directory", 384, 8, 86, 17)
$Label5 = GUICtrlCreateLabel("Local Directory", 8, 67, 104, 17)
$Button4 = GUICtrlCreateButton("select folder", 386, 88, 115, 25)
$Button3 = GUICtrlCreateButton("ESCI", 388, 136, 115, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
    
;////////////////////////////////////////////////////////////////////
;//   MAIN
;////////////////////////////////////////////////////////////////////
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button4
            _select_folder()
    EndSwitch
WEnd

;////////////////////////////////////////////////////////////////////
;//   FUNCs
;////////////////////////////////////////////////////////////////////

FUNC _select_folder()
    $sDir = FileSelectFolder("Select FTP folder", "", 0, @ScriptDir)
    If StringRight($sDir, 1) <> "\" Then $sDir &= "\"

    If $sDir = "\" Then
        ToolTip("user abort",0,0)
        Sleep(500)
        ToolTip("",0,0)
    Elseif $sDir <> "\" Then
                  GUICtrlSetData($l,$sDir)
    EndIf

EndFunc
Edited by Vitas

_____________________________________________________________________________

Link to comment
Share on other sites

And simple optimization:

FUNC _select_folder()
    $sDir = FileSelectFolder("Select FTP folder", "", 0, @ScriptDir)
    If @error <> 1 Then
        GUICtrlSetData($l,$sDir)
    Else
        ToolTip("user abort",0,0)
        Sleep(500)
        ToolTip("",0,0)
    EndIf
EndFunc
Edited by Vitas

_____________________________________________________________________________

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...