MyEarth Posted February 8, 2014 Share Posted February 8, 2014 (edited) With FileSaveDialog using multiple extension, how can i know what is the extension selected? I need to make 2 different function based on the extension selected in the dialog, the return value is only the path EDIT: Ticket http://www.autoitscript.com/trac/autoit/ticket/2648 Edited February 8, 2014 by MyEarth Link to comment Share on other sites More sharing options...
JohnOne Posted February 8, 2014 Share Posted February 8, 2014 The return value is the path and file name including extension. It's a very simple process to get the extension from that, and worth figuring out yourself if you cannot do it after over 2 years here. StringInStr and StringMid Or simple StringSplit will suffice. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
MyEarth Posted February 8, 2014 Author Share Posted February 8, 2014 (edited) I don't see any extension, only the pathfilename $var = FileSaveDialog("Choose a name.", @ScriptDir, "Scripts (*.au3)|Text files (*.txt)", 2, "MYNAME") If @error Then MsgBox(4096, "", "Save cancelled.") Else MsgBox(4096, "", "You chose " & $var) EndIf Edited February 8, 2014 by MyEarth Link to comment Share on other sites More sharing options...
Developers Jos Posted February 8, 2014 Developers Share Posted February 8, 2014 (edited) Retrieve the extension from the returned file in variable $var by getting the right 4 characters or use #include <WinAPIShPath.au3> _WinAPI_PathFindExtension ( $sPath ) Jos Edited February 8, 2014 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 8, 2014 Moderators Share Posted February 8, 2014 MyEarth,The dialog does not add an extension automatically - you still need to do it manually. That is why you do not see an extension. And this is a Windows "feature" - nothing to do with AutoiI. You need to add some code like this to check if it has been done:$var = FileSaveDialog("Choose a name.", @ScriptDir, "Scripts (*.au3)|Text files (*.txt)", 2, "MYNAME") If @error Then MsgBox(4096, "", "Save cancelled.") Else Switch StringRight($var, 4) Case ".txt", ".au3" ; Good extension Case Else $sExt = InputBox("Add extension", "Please add an extension: '.txt' or '.au3'") $var &= $sExt EndSwitch MsgBox(4096, "", "You chose " & $var) EndIfAll clear? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
MyEarth Posted February 8, 2014 Author Share Posted February 8, 2014 (edited) No, i don't belive. Ok i need to set manually the extension and i know, it's not a problem to add $var & $extension But how i can set it if i don't have any returned value about extension from the FileSaveDialog? How can i know if a user select Scripts (*.au3) or Txt (*.txt)? Don't tell me I need to make two dialog, one for filename and one for extension I don't have any extension in the returned value, only: C:PathMYNAME Edited February 8, 2014 by MyEarth Link to comment Share on other sites More sharing options...
Developers Jos Posted February 8, 2014 Developers Share Posted February 8, 2014 No, i don't belive. Ok i need to set manually the extension and i know, it's not a problem to add $var & $extension But how i can set it if i don't have any returned value from the FileSaveDialog? How can i know if a user select Scripts (*.au3) or Txt (*.txt)? Don't tell me I need to make two dialog, one for filename and one for extension And again, i don't have any extension in the returned value, only: C:PathMYNAME What is the filename you selected or typed in the FileSaveDialog() box? Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 8, 2014 Moderators Share Posted February 8, 2014 MyEarth,No, i don't beliveFine, then you are on your own as far as I am concerned. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
JohnOne Posted February 8, 2014 Share Posted February 8, 2014 Odd, the file name is definitely included for me. Also, do not rely on last 4 chars, as an extension can be any length. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
MyEarth Posted February 8, 2014 Author Share Posted February 8, 2014 (edited) $var = FileSaveDialog("Choose a name.", @ScriptDir, "Scripts (*.au3)|Text files (*.txt)", 2, "MYNAME") If @error Then MsgBox(4096, "", "Save cancelled.") Else MsgBox(4096, "", "You chose " & $var) EndIf What is the sense to make a multiple choice when i don't know what is the choice? That's all i what to know, what is the extension selected in the combobox and then i'll add it for save the file ( as i have say at the first post two different function based on that choice ) Edited February 8, 2014 by MyEarth Link to comment Share on other sites More sharing options...
Starg Posted February 8, 2014 Share Posted February 8, 2014 Use _WinAPI_GetSaveFileName(). '?do=embed' frameborder='0' data-embedContent>> Link to comment Share on other sites More sharing options...
MyEarth Posted February 8, 2014 Author Share Posted February 8, 2014 (edited) Starg thanks that WinAPI function return the extension based on the combobox so without any other solution using the internal FileSaveDialog i'll use that. But i think ( my opinion, without any offence for anyone ) Jos need to add to the internal FileSaveDialog the extension return value or is useless to add a multiple choice because i don't know what is the user choice from the combobox. Edited February 8, 2014 by MyEarth Link to comment Share on other sites More sharing options...
JohnOne Posted February 8, 2014 Share Posted February 8, 2014 We do know what the user choose, we parse the extension from the return value of the function. If you don't have that, then something might be wrong with your windows installation. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Developers Jos Posted February 8, 2014 Developers Share Posted February 8, 2014 Starg thanks that WinAPI function return the extension based on the combobox so without any other solution using the internal FileSaveDialog i'll use that. But i think ( my opinion, without any offence for anyone ) Jos need to add to the internal FileSaveDialog the extension return value or is useless to add a multiple choice because i don't know what is the user choice from the combobox. Understand what you are saying and know what this issue is now. It should be just a matter of setting .lpstrDefExt to "". Just make a Bugreport and I won't be me making any changes to AutoIt3 core and "only" maintain the SciTE4AutoIt3 and Utilities stuff. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
MyEarth Posted February 8, 2014 Author Share Posted February 8, 2014 Thanks jos, i'll make the bug report in a couple of hour, i'm outside at this moment. Link to comment Share on other sites More sharing options...
Developers Jos Posted February 8, 2014 Developers Share Posted February 8, 2014 With this Modification, your example will default to the first supplied extension and show "MYNAME.au3" when running your snippet in the FileName field: $var = FileSaveDialog("Choose a name.", @ScriptDir, "Scripts (*.au3)|Text files (*.txt)", 2, "MYNAME") When a filename without an extension is provided in the FileName field, the extension is added which is selected in the "Save as Type" dropdownbox to the returned value in $var. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
MyEarth Posted February 8, 2014 Author Share Posted February 8, 2014 Yes, perfect. Just for understand, for use this modification ( when you done it after the bug report ) i need to download a BETA version? Would be great if i can use it with the stable if is possible, a beta is always a beta. If is it not possible for now i'll use _WinAPI_GetSaveFileName Link to comment Share on other sites More sharing options...
Developers Jos Posted February 8, 2014 Developers Share Posted February 8, 2014 Yes, perfect. Just for understand, for use this modification ( when you done it after the bug report ) i need to download a BETA version? Would be great if i can use it with the stable if is possible, a beta is always a beta. If is it not possible for now i'll use _WinAPI_GetSaveFileName I have informed Jon about the modification that needs to be made to implement this change, but leave it to him to decide whether or not he wants to make the modification. So just created the Bug report to get this on record and link to this thread and lets see what happens. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
MyEarth Posted February 8, 2014 Author Share Posted February 8, 2014 Ticket: http://www.autoitscript.com/trac/autoit/ticket/2648 Link to comment Share on other sites More sharing options...
JohnOne Posted February 8, 2014 Share Posted February 8, 2014 Wonder if someone could explain whatever the problem is here. I don't understand how you can select a file without an extension unless *.* is used in filter. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now