Jump to content

Recommended Posts

Posted (edited)

When I am am selecting Add button, the Browse window opens up. I have given up the Input Box so that any file path when selected would be showing up in the Input Box. Something as shown in the below Pic.

Can someone please help here...

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <FileConstants.au3>

#Region
$Form = GUICreate("Form", 688, 125, 635, 317)
$Find = GUICtrlCreateInput("", 40, 56, 457, 24)
$ADD = GUICtrlCreateButton("ADD", 520, 56, 115, 25)
GUISetState(@SW_SHOW)
#EndRegion

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $ADD
            GUICtrlSetData($Find, Browse())

    EndSwitch
WEnd


Func Browse()
    ; Create a constant variable in Local scope of the message to display in FileOpenDialog.
    Local Const $Message = "Hold down Ctrl or Shift to choose multiple files."

    ; Display an open dialog to select a list of file(s).
    Local $Browse = FileOpenDialog($Message, @WindowsDir & "\", "All Files (*.*)", $FD_FILEMUSTEXIST + $FD_MULTISELECT)
    If @error Then
        ; Display the error message.

        ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder.
        FileChangeDir(@ScriptDir)
    Else
        ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder.
        FileChangeDir(@ScriptDir)

        ; Replace instances of "|" with @CRLF in the string returned by FileOpenDialog.
        $Browse = StringReplace($Browse, "|", @CRLF)

    MsgBox(0, "", $Browse)

    EndIf
EndFunc   ;==>Browse

 

 

Test.thumb.jpg.b910dfdb9ed4f5fd408f256db

Edited by DigDeep
Posted (edited)

DigDeep,

Just return the value from the function call...

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <FileConstants.au3>

#Region
$Form = GUICreate("Form", 688, 125, 635, 317)
$Find = GUICtrlCreateInput("", 40, 56, 457, 24)
$ADD = GUICtrlCreateButton("ADD", 520, 56, 115, 25)
GUISetState(@SW_SHOW)
#EndRegion



While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg

        Case $GUI_EVENT_CLOSE
            Exit

        Case $ADD
            GUICtrlSetData($Find, Browse())

    EndSwitch

WEnd





Func Browse()
    ; Create a constant variable in Local scope of the message to display in FileOpenDialog.
    Local Const $Message = "Hold down Ctrl or Shift to choose multiple files."

    ; Display an open dialog to select a list of file(s).
    Local $Browse = FileOpenDialog($Message, @WindowsDir & "\", "All Files (*.*)", $FD_FILEMUSTEXIST + $FD_MULTISELECT)
    If @error Then
        ; Display the error message.

        ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder.
        FileChangeDir(@ScriptDir)
    Else
        ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder.
        FileChangeDir(@ScriptDir)

        ; Replace instances of "|" with @CRLF in the string returned by FileOpenDialog.
        $Browse = StringReplace($Browse, "|", @CRLF)
        ConsoleWrite($Browse & @CRLF)

    return $browse  ; <----------------------------------------
    ;MsgBox(0, "", $Browse)

    EndIf

EndFunc   ;==>Browse

kylomas

edit: if you want to return multiple files you should use a list or listview

Edited by kylomas
additional data

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...