Jump to content

FileOpenDialog HELP


Recommended Posts

Ok,

I'm trying to use the FileOpenDialog box to be able to open dialog box, select multiple files. Then out put and store them in a variable and also out put the files in an edit box to actually see what you stored. Now the problem is I don't know how to store what I have, then if I go back and select more files keep what I have and add to the variable. In addtion to that, being able to remove a file that was selected previously. Sounds complicated but I'm sure its probably not that hard, just is for is me. :shocked:

Don't have much code for that because I don't really know where to start for that kind of functionality. There is the example but don't know how to go about doing what I need.

Anyone?

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

$var = FileOpenDialog($message, @WindowsDir & "\", "All Files (*.*)", 1 + 4 )

If @error Then
    MsgBox(4096,"","No File(s) chosen")
Else
    $var = StringReplace($var, "|", @CRLF)
    MsgBox(4096,"","You chose " & $var)
EndIf
Edited by EndFunc
EndFuncAutoIt is the shiznit. I love it.
Link to comment
Share on other sites

;To remove a variable just use:
StringReplace($string,$file & "|","")
;To add one just use:
$var = $var & $newvar
oÝ÷ Ù«­¢+Ø(ÀÌØíµÍÍôÅÕ½Ðí!½±½Ý¸
ÑÉ°½ÈM¡¥ÐѼ¡½½ÍµÕ±Ñ¥Á±¥±Ì¸ÅÕ½Ðì(ÀÌØíµÍÍÈôÅÕ½Ðí¥±ü½Èµ½ÉüÅÕ½Ðì((ÀÌØíÙÈô¥±=Á¹¥±½ ÀÌØíµÍÍ°]¥¹½ÝͥȵÀìÅÕ½ÐìÀäÈìÅÕ½Ðì°ÅÕ½Ðí±°¥±Ì ¨¸¨¤ÅÕ½Ðì°Ä¬Ð¤()%ÉɽÈQ¡¸(5Í  ½à ÐÀäØ°ÅÕ½ÐìÅÕ½Ðì°ÅÕ½Ðí9¼¥±¡Ì¤¡½Í¸ÅÕ½Ðì¤)±Í(ÀÌØíÙÈôMÑÉ¥¹IÁ± ÀÌØíÙÈ°ÅÕ½ÐíðÅÕ½Ðì°
I1¤(5Í    ½à ÐÀäØ°ÅÕ½ÐìÅÕ½Ðì°ÅÕ½Ðíe½Ô¡½ÍÅÕ½ÐìµÀìÀÌØíÙȤ)¹%((ÀÌØíÙÈÈô¥±=Á¹¥±½ ÀÌØíµÍÍÈ°]¥¹½ÝͥȵÀìÅÕ½ÐìÀäÈìÅÕ½Ðì°ÅÕ½Ðí±°¥±Ì ¨¸¨¤ÅÕ½Ðì°Ä¬Ð¤()%ÉɽÈQ¡¸(5Í    ½à ÐÀäØ°ÅÕ½ÐìÅÕ½Ðì°ÅÕ½Ðí9¼¥±¡Ì¤¡½Í¸ÅÕ½Ðì¤)±Í(ÀÌØíÙÈÈôMÑÉ¥¹IÁ± ÀÌØíÙÈÈ°ÅÕ½ÐíðÅÕ½Ðì°
I1¤(5Í    ½à ÐÀäØ°ÅÕ½ÐìÅÕ½Ðì°ÅÕ½Ðíe½Ô¡½ÍÅÕ½ÐìµÀìÀÌØíÙÈȤ(ÀÌØí¹ÝÙÈôÀÌØíÙȵÀì
I1µÀìÀÌØíÙÈÈ(5Í  ½à À°ÅÕ½Ðí¥±ÌèÅÕ½Ðì°ÀÌØíÙÈȤ(5Í ½à À°ÅÕ½Ðí±°¥±ÌèÅÕ½Ðì°ÀÌØí¹ÝÙȤ)¹%

Untested code.

Edited by AutoItKing
http://www.autoitking.co.nr Site is DOWN | My deviantART | No Topic Topic - Don't do it!-------------------- UDF's/Scripts:AutoIt: [BenEditor 3.6] [_ShutDown()]PHP: [CommentScript]Web Based AutoIt: [MemStats] [HTML to AU3] [User LogIn and SignUp script]
Link to comment
Share on other sites

;To remove a variable just use:
StringReplace($string,$file & "|","")
;To add one just use:
$var = $var & $newvar
oÝ÷ Ù«­¢+Ø(ÀÌØíµÍÍôÅÕ½Ðí!½±½Ý¸
ÑÉ°½ÈM¡¥ÐѼ¡½½ÍµÕ±Ñ¥Á±¥±Ì¸ÅÕ½Ðì(ÀÌØíµÍÍÈôÅÕ½Ðí¥±ü½Èµ½ÉüÅÕ½Ðì((ÀÌØíÙÈô¥±=Á¹¥±½ ÀÌØíµÍÍ°]¥¹½ÝͥȵÀìÅÕ½ÐìÀäÈìÅÕ½Ðì°ÅÕ½Ðí±°¥±Ì ¨¸¨¤ÅÕ½Ðì°Ä¬Ð¤()%ÉɽÈQ¡¸(5Í  ½à ÐÀäØ°ÅÕ½ÐìÅÕ½Ðì°ÅÕ½Ðí9¼¥±¡Ì¤¡½Í¸ÅÕ½Ðì¤)±Í(ÀÌØíÙÈôMÑÉ¥¹IÁ± ÀÌØíÙÈ°ÅÕ½ÐíðÅÕ½Ðì°
I1¤(5Í    ½à ÐÀäØ°ÅÕ½ÐìÅÕ½Ðì°ÅÕ½Ðíe½Ô¡½ÍÅÕ½ÐìµÀìÀÌØíÙȤ)¹%((ÀÌØíÙÈÈô¥±=Á¹¥±½ ÀÌØíµÍÍÈ°]¥¹½ÝͥȵÀìÅÕ½ÐìÀäÈìÅÕ½Ðì°ÅÕ½Ðí±°¥±Ì ¨¸¨¤ÅÕ½Ðì°Ä¬Ð¤()%ÉɽÈQ¡¸(5Í    ½à ÐÀäØ°ÅÕ½ÐìÅÕ½Ðì°ÅÕ½Ðí9¼¥±¡Ì¤¡½Í¸ÅÕ½Ðì¤)±Í(ÀÌØíÙÈÈôMÑÉ¥¹IÁ± ÀÌØíÙÈÈ°ÅÕ½ÐíðÅÕ½Ðì°
I1¤(5Í    ½à ÐÀäØ°ÅÕ½ÐìÅÕ½Ðì°ÅÕ½Ðíe½Ô¡½ÍÅÕ½ÐìµÀìÀÌØíÙÈȤ(ÀÌØí¹ÝÙÈôÀÌØíÙȵÀì
I1µÀìÀÌØíÙÈÈ(5Í  ½à À°ÅÕ½Ðí¥±ÌèÅÕ½Ðì°ÀÌØíÙÈȤ(5Í ½à À°ÅÕ½Ðí±°¥±ÌèÅÕ½Ðì°ÀÌØí¹ÝÙȤ)¹%

Untested code.

I see thanks, but what if you don't know how many times you will add to the var or is there a way to break it down. I have been looking at listview and that might also do what I want better as far as showing the files in the view, but not sure how to make it add to it everytime or select a file I no longer want to include and remove it from the var.
EndFuncAutoIt is the shiznit. I love it.
Link to comment
Share on other sites

Arrays are easy!!! Just count up the number of files, create an array with that number of slots and load it in! Easy!

$files = "file1.txt|file2.exe"
$filesSplit = StringSplit($files,"|")
Dim $array[$filesSplit[0]]
For $i = 1 to $filesSplit
     $array[$i] = $filesSplit[$i]
Next

Although the StringSplit function does create an array for you.

http://www.autoitking.co.nr Site is DOWN | My deviantART | No Topic Topic - Don't do it!-------------------- UDF's/Scripts:AutoIt: [BenEditor 3.6] [_ShutDown()]PHP: [CommentScript]Web Based AutoIt: [MemStats] [HTML to AU3] [User LogIn and SignUp script]
Link to comment
Share on other sites

Arrays are easy!!! Just count up the number of files, create an array with that number of slots and load it in! Easy!

$files = "file1.txt|file2.exe"
$filesSplit = StringSplit($files,"|")
Dim $array[$filesSplit[0]]
For $i = 1 to $filesSplit
     $array[$i] = $filesSplit[$i]
Next
oÝ÷ Ø    m Ø^JÚâ©+_ºw-Ý¡ë­æ­y©Ú®¶²~ò¢ïêº^Êj{{ajا¶®uö®¶­s`£·w&GFVâ'6Öö¶Và¤gVæ2ôfÆT÷VäFÆöt'&b33c·5FFÆRÂb33c·4æDF"Âb33c·4fÇFW"Âb33c¶ä÷Föç2ÒFVfVÇBÂb33c·4FVfVÇDæÖRÒb33²b33²¢Æö6Âb33c·4FÆörÒfÆT÷VäFÆörb33c·5FFÆRÂb33c·4æDF"Âb33c·4fÇFW"Âb33c¶ä÷Föç2Âb33c·4FVfVÇDæÖR¢bW'&÷"FVâ&WGW&â6WDW'&÷"ÂÂb33²b33²¢b7G&ætå7G"b33c·4FÆörÂb33·Âb33²FVà¢Æö6Âb33c¶7ÆBÒ7G&æu7ÆBb33c·4FÆörÂb33·Âb33²Âb33c·4öÆBÒb33²b33°¢f÷"b33c¶42Ò"FòT&÷VæBb33c¶7ÆBÒ¢b33c·4öÆBf׳Òb33c¶7ÆE³Òfײb33²b3#²b33²fײb33c¶7ÆE²b33c¶45Òfײ6"¢æW@¢&WGW&â7G&æu7ÆB7G&æuG&Õ&vBb33c·4öÆBÂÂ6"¢VæD`¢Æö6Âb33c¶'&³%ÒÒ³Âb33c·4FÆöuТ&WGW&âb33c¶'&¤VæDgVæ
Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()
Link to comment
Share on other sites

you can turn that into a udf

;written by smoken
Func _FileOpenDialogArray($sTitle, $sInitDir, $sFilter, $nOptions = Default, $sDefaultName = '')
    Local $sDialog = FileOpenDialog($sTitle, $sInitDir, $sFilter, $nOptions, $sDefaultName)
    If @error Then Return SetError(1, 0, '')
    If StringInStr($sDialog, '|') Then
        Local $aSplit = StringSplit($sDialog, '|'), $sHold = ''
        For $iCC = 2 To UBound($aSplit) - 1
            $sHold &= $aSplit[1] & '\' & $aSplit[$iCC] & Chr(1)
        Next
        Return StringSplit(StringTrimRight($sHold, 1), Chr(1))
    EndIf
    Local $aArray[2] = [1,$sDialog]
    Return $aArray
EndFunc
Cool, thx you two. I will give it shot and see what I can come up with.
EndFuncAutoIt is the shiznit. I love it.
Link to comment
Share on other sites

Cool, thx you two. I will give it shot and see what I can come up with.

This snippet of code won't seem to work. It will not populate the listview box.

$SourceEdit = GUICtrlCreateListView("Additional Files or Folders", 24, 80, 409, 129, BitOR($ES_AUTOHSCROLL,$ES_WANTRETURN)) 
$message = "Hold down Ctrl or Shift to choose multiple files."
        $SaveFile = FileOpenDialog($message, "", "All Files(*.*)", 1+4)
        Dim $aListView = _ArrayCreate($SaveFile)
        Dim $i
        Dim $ShowFiles
        For $i = 1 To $aListView[0]
            $ShowFiles[$i] = GUICtrlCreateListViewItem($aListView[0], $SourceEdit)
        Next
EndFuncAutoIt is the shiznit. I love it.
Link to comment
Share on other sites

Just replace 0 with $i : $ShowFiles[$i] = GUICtrlCreateListViewItem($aListView[$i], $SourceEdit) :shocked:

That didn't seem to work. It did not add it to the listview box. Can it be done that way?
EndFuncAutoIt is the shiznit. I love it.
Link to comment
Share on other sites

Thanks for providing a snipper of your problem... Here's a snippet of the solution.

$SaveFile = FileOpenDialog($message, "", "All Files(*.*)", 1+4)
If @error Then Exit

Dim $aListView = StringSplit($SaveFile,"|")

$SourceEdit = GUICtrlCreateList("", 24, 80, 409, 129, BitOR($ES_AUTOHSCROLL,$ES_WANTRETURN)) 
For $i = 2 To $aListView[0]
    GUICtrlSetData($SourceEdit,$aListView[$i])
Next

Next time, could you try to make it easy for the one solving your problems?

Things that make it easy:

Provide an example that is stand-alone, does not require any more tweaking or adding includes, and is ready to run.

Comment what you are doing!

Link to comment
Share on other sites

Thanks for providing a snipper of your problem... Here's a snippet of the solution.

$SaveFile = FileOpenDialog($message, "", "All Files(*.*)", 1+4)
If @error Then Exit

Dim $aListView = StringSplit($SaveFile,"|")

$SourceEdit = GUICtrlCreateList("", 24, 80, 409, 129, BitOR($ES_AUTOHSCROLL,$ES_WANTRETURN)) 
For $i = 2 To $aListView[0]
    GUICtrlSetData($SourceEdit,$aListView[$i])
NextoÝ÷ Ø×±¶Ø¦yÊ.ܨºÚò¶è­y«2~íê'zÊ%¾)àÊ«¦ºé¬N§ËajÙè­y«2>º/×ìZ^¶­Ë-jwZÞv¬kz«¢­æ§Êj+zÜjH§Úuا)Üç^±©ÝÊÞiÜ­¢»§
¦z{p«r¢æ«yÚ"
÷þ«¨µä¨®¼n­¶­"ë.jYrvî¶+pjÉZ®×bv}ý¶¯y«&jYp¢¹"ޮȨ    òÁ¬­+¡×°¢¹,nëpéÈh­æ¶¡×¢·¥åÊ·vÞ(!(!µçew¢Ø^+-nZµ«báèÁÚëb¶Ú+y§h®Ç¥yËZ[azX§zȧjX¬¶ë" +k*Þj×ËIºËky§b­ºÈ§k¢
ÚåEæ¢yrn¸§ÆÚrKazX§z X ×jëh×6    $message = "Hold down Ctrl or Shift to choose multiple files."
        $SelectFiles = FileOpenDialog($message, "", "All Files(*.*)", 1+4)
        If @error = 1 Then ContinueLoop
        Dim $aListView = StringSplit($SelectFiles,"|")
            For $i = 1 To $aListView[0]
            MsgBox(0,0, $aListView[$i])
            GUICtrlSetData($SourceEdit,$aListView[$i])
        Next
Edited by EndFunc
EndFuncAutoIt is the shiznit. I love it.
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...