Jump to content

FileSelectFolder - Question about output


Thrawn
 Share

Recommended Posts

Hello all,

I want my program to use the FileSelectFolder command to select a directory name and pass it into an input box.

Everything works fine except 1 thing: The output of that command is the FULL path to the directory. I just want it to include the directory name, not more.

Is there a command or something like this to solve my problem? I searched the forums and looked into the documentation but I didn't find anything.

Here is my script:

#include <GuiConstants.au3>

; GUI
GuiCreate("FileSelectFolder problem", 400, 207)
GuiSetIcon(@SystemDir & "\cmd.exe", 0)
Opt("TrayIconHide",1);Kein Icon in tray
;-----------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------
; TAB 1
$opendirectory = GUICtrlCreateButton("...", 234, 47, 20 ,20)
GUICtrlCreateButton("OK", 259, 47, 22 ,20)

GuiSetState()

While 1
 $msg = GuiGetMsg()
 
    Select
    Case $msg = $GUI_EVENT_CLOSE
     ;Destroy the GUI including the controls
         GUIDelete()
     ;Exit the script
         Exit
     Case $msg = $opendirectory 
        $directory = FileSelectFolder("Choose a folder.", @ScriptDir & "\Games\", -1, @ScriptDir)
        GUICtrlCreateInput($directory, 20, 47, 208, 20)
        
    EndSelect
WEnd

GUIDelete()

Exit

Thanks in advance,

Thrawn

Link to comment
Share on other sites

#include <GuiConstants.au3>

; GUI
GUICreate("FileSelectFolder problem", 400, 207)
GUISetIcon(@SystemDir & "\cmd.exe", 0)
opt("TrayIconHide", 1);Kein Icon in tray
;-----------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------
; TAB 1
$opendirectory = GUICtrlCreateButton("...", 234, 47, 20, 20)
$input = GUICtrlCreateInput("", 20, 47, 208, 20)
GUICtrlCreateButton("OK", 259, 47, 22, 20)

GUISetState()

While 1
   $msg = GUIGetMsg()
   
   Select
      Case $msg = $GUI_EVENT_CLOSE
        ;Destroy the GUI including the controls
         GUIDelete()
        ;Exit the script
         Exit
      Case $msg = $opendirectory
         $directory = FileSelectFolder("Choose a folder.", @ScriptDir & "\Games\", -1, @ScriptDir)
         If StringLen($directory) Then
            $directory = StringSplit($directory, "\")
            GUICtrlSetData($input, $directory[$directory[0]])
         EndIf
   EndSelect
WEnd

GUIDelete()

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.

 

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