Jump to content

File Input field similar to a HTML file_upload_field


Recommended Posts

Hi everyone

I'm sure this question would be easy to be answered by an advanced autoit user. I need a way to let the user choose a directory on the harddisk in "explorer style". I'll only need the path (exp. "C:\My docments\holidays 2005") to imply in my GUI.

Thanks for any help. Hope you know what I mean ;-)

Greetings

Link to comment
Share on other sites

You can take a look at FileOpenDialog:

FileOpenDialog

--------------------------------------------------------------------------------

Initiates a Open File Dialog.

FileOpenDialog ( "title", "init dir", "filter" [, options [, "default name"]] )

Parameters

title Title text of the Dialog GUI.

init dir Initial directory selected in the GUI file tree.

filter File type single filter such as "All (*.*)" or "Text files (*.txt)" or multiple filter groups such as "All (*.*)|Text files (*.txt)" (See Remarks).

options [optional] Dialog Options: To use more than one option, add the required values together.

1 = File Must Exist (if user types a filename)

2 = Path Must Exist (if user types a path, ending with a backslash)

4 = Allow MultiSelect

8 = Prompt to Create New File (if does not exist)

default name [optional] Suggested file name for the user to open.

And an example fom the same help file:

$message = "Hold down Ctrl or Shift to choose multiple files."

$var = FileOpenDialog($message, "C:\Windows\", "Images (*.jpg;*.bmp)", 1 + 4 )

If @error Then
    MsgBox(4096,"","No File(s) chosen")
Else
    $var = StringReplace($var, "|", @CRLF)
    MsgBox(4096,"","You chose " & $var)
EndIf
Edited by enaiman

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Link to comment
Share on other sites

FileSelectFolder should be the best possibility.

The INI file handling could be done with the INIxxxxx commands, in particular i suppose IniDelete should do the trick.

Now we all are waiting for your next question :)

Link to comment
Share on other sites

@Dschingis: Next question? I'll give you one.

I want to create a dynamic GUICtrlCreateCombo List with values from each section in my Ini File. This works as well. But if I want to use the value from the selected entrie of the Combo List I always get "0", and not the selected value like "My Site". I use GUICtrlRead to get the $var from the combo list. But it doesn't work.

Any Idea? I will post my source tomorrow if I don't forget.

Greetings

Edited by da.eXecutoR
Link to comment
Share on other sites

@Dschingis: Next question? I'll give you one.

I want to create a dynamic GUICtrlCreateCombo List with values from each section in my Ini File. This works as well. But if I want to use the value from the selected entrie of the Combo List I always get "0", and not the selected value like "My Site". I use GUICtrlRead to get the $var from the combo list. But it doesn't work.

Any Idea? I will post my source tomorrow if I don't forget.

Greetings

How you use that GUICtrlRead to get the $var?

This is just a raw example of my one list-code but it is similar...

GUICreate("List", 250, 150)
$read = GUICtrlCreateButton("read text", 90, 5, 50, 20)

$list = GUICtrlCreateList("" , 5, 5,  70, 180);,$LVS_SORTDESCENDING)
GUICtrlSetData($list,"part1|part2|part3|part4|part5")

$part1 = GUICtrlCreateListViewItem("part1",$list)
$part2 = GUICtrlCreateListViewItem("part2",$list)
$part3 = GUICtrlCreateListViewItem("part3",$list)
$part4 = GUICtrlCreateListViewItem("part4",$list)
GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $read
            $readlist = GUICtrlRead($list, 0)
            IniWrite(@ScriptDir & "\data.ini", "these were read", "data" , $readlist)
            Exit        
    EndSelect
WEnd

Could you send your code here for us to check.

Edited by freeman7

-------------------------------------------------------People keeping order at their stuff are just too lazy to search anything...Test these:Easy-to-use notepad

Link to comment
Share on other sites

Okay, here it is:

;AUSWAHLLISTE GENERIEREN FOR ACTIVATE
    $Combo_1 = GuiCtrlCreateCombo("default", 20, 40, 270, 80)
    $i = 0
    $sections = IniReadSectionNames("data/sitesdb.ini")
    $combo1_vars = ""
    For $i = 1 To $sections[0]
            $combo1_vars = $combo1_vars  & "|" & (IniRead("data/sitesdb.ini",$sections[$i],"Sitename","default"))
        Next
    $Combo_1 = GUICtrlSetData(-1,$combo1_vars,"default")
oÝ÷ ØZ½æºÛh«­¢+Ø(ÀÌØíɵ½ÙôÕ¥
Ñɱ
ÉÑ    ÕÑѽ¸ ÅÕ½Ðí¹Ñɹ¸ÅÕ½Ðì°ÌÄÀ°ÄÌÀ°ØÀ°ÈÀ¤(oÝ÷ Ùh­Øb±û§rب«­¢+Ø(íM¥Ñ¹Ñɹ¸)
ÍÀÌØíµÍôÀÌØíɵ½Ù(%5Í   ½à ØаÅÕ½ÐíM¥Ñ5¹ÈÅÕ½Ðì°ÅÕ½ÐíM¥Ñ¹ÑɹÐèÅÕ½ÐìµÀìU%
ÑɱI ÀÌØí
½µ½|Ĥ¤

The List appears correct with all the values from the Ini File, but when I select one and click on my button the message box says: "Seite entfernt: 0" instead of "Seite Entfernt: My name from the ini file [or what ever in the ini file stands for the Sitename]

Any Idea?

Greetings

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