Jump to content

New style FileSelectFolder


trancexx
 Share

Recommended Posts

Newer systems have nicer looking "Browse for folder" UI than older does. AutoIt internally calls older version.

Since some time AutoIt can natively access, by definition early bound objects, using special technique of late binding. Function that does this is ObjCreateInterface(). Considering most of the Windows is COM based the advantages are big, you just have to learn how to take them.

This small example (attached FileSelectFolder.au3) shows how to create object of IFileDialog interface and by calling its methods customize and invoke "select folder" dialog. In case of older systems where IFileDialog isn't available the function will call internal AutoIt's FileSelectFolder(), so it should be safe to use in any environment.

Example of usage is from the help file for normal dialog:

#include "FileSelectFolder.au3"

Local Const $sMessage = "Select a folder"

; Display an open dialog to select a folder.
Local $sFileSelectFolder = FileSelectFolder2($sMessage, "")
If @error Then
    MsgBox(4096, "", "No folder was selected.")
Else
    MsgBox(4096, "", "You chose the following folder:" & @CRLF & $sFileSelectFolder)
EndIf

...And the UDF:

FileSelectFolder.au3

Edited by trancexx

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

Where I can read about possible value for this parameter: "$iFlag" ?

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

wakillon position is remembered per app in case of default parent window (0) - I believe. Beta AutoIt is new application, try moving the UI to new position. Normally you would "attach" it to your GUI by passing parent window handle.

 

Ok thanks.

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

Is there any way you display a list of files in such a way as to display a list of files in the "Detail view" ?

Edited by mlipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

(Thanks for this; considering what an evil thing the default folder-select is, I'm surprised there aren't more responses here.)

A little bit of experimentation using BitOR($FOS_PICKFOLDERS, $FOS_ALLOWMULTISELECT, $FOS_CREATEPROMPT) for the options is not exactly having the effect I was after.

While multiple folders can be selected (and will even display as a quoted/space-separated list in the edit control), that multi-string is not returned as expected - would extra calisthenics be required for this?

And, manually entered folders (to replicate the missing "Create Folder" button) will actually invoke the prompt ("Does not exist - Create it?") as expected, except it's always followed by an "invalid folder" error, even if the path is manually supplied.

Or is this just asking too much of the poor IFileDialog?

Link to comment
Share on other sites

This seems... Awesome!

But would it break on lower systems with windows XP?

Could I use it in a release app where the environment is unsupervised?

Edited by DatMCEyeBall

"Just be fred, all we gotta do, just be fred."  -Vocaliod

"That is a Hadouken. A KAMEHAMEHA would have taken him 13 days and 54 episodes to form." - Roden Hoxha

@tabhooked

Clock made of cursors ♣ Desktop Widgets ♣ Water Simulation

Link to comment
Share on other sites

(Thanks for this; considering what an evil thing the default folder-select is, I'm surprised there aren't more responses here.)

A little bit of experimentation using BitOR($FOS_PICKFOLDERS, $FOS_ALLOWMULTISELECT, $FOS_CREATEPROMPT) for the options is not exactly having the effect I was after.

While multiple folders can be selected (and will even display as a quoted/space-separated list in the edit control), that multi-string is not returned as expected - would extra calisthenics be required for this?

And, manually entered folders (to replicate the missing "Create Folder" button) will actually invoke the prompt ("Does not exist - Create it?") as expected, except it's always followed by an "invalid folder" error, even if the path is manually supplied.

Or is this just asking too much of the poor IFileDialog?

Aha multiple folders, yes I can do that.

...Will update the OP.

Why poor?

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

Thanks again.

Why poor?

 

I hate COM (with a passion), so always imagine these objects as sad little entities being poked and prodded by a bunch of kooks with sticks until they do what we want them to.  So, even though I hate them, anthropomorphically they deserve some semblance of sympathy: hence, "poor". :)

Link to comment
Share on other sites

Thanks again.

 

I hate COM (with a passion), so always imagine these objects as sad little entities being poked and prodded by a bunch of kooks with sticks until they do what we want them to.  So, even though I hate them, anthropomorphically they deserve some semblance of sympathy: hence, "poor". :)

Then unfortunately you can't understand Windows systems.

AutoIt was never object-friendly, the worst internal AutoIt code was objects related one. It was implemented on very basic level and even that was poorly done. With latest development, even though "latest" in AutoIt means shit, plenty of things have been changed, improved, rewritten. it's worth using now, really.

...But like almost everything with AutoIt, ignorance wins at the end and somehow finds way to pull it back into the little black box. Luckily, some good things manage to survive the process. 

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

Then unfortunately you can't understand Windows systems.

There's a lot to be said for humour.  :ermm:  I never said I couldn't use it, it's just that I hate it; like Liver and Onions - sure, I can eat it if I have to, but I'd have to have a gun to my head.

At least I can grasp the context of it better in AutoIt than in VBS where I was forced to learn some of it in the first place (with that gun to my head).  There's a reason God gives us nice juicy DLL calls with pointers we can sink our teeth into.  I dislike the "let me hold your hand" approach because it always seems to jump right off the cliff just when you feel you're getting the hang of it - but then again, I suppose that's the moral of scripting in a nutshell... anything worth doing is worth doing the hard way.  (That, and the documentation [in Windows itself, not AutoIt] is atrocious.)

Maybe it's just me.

(Thanks for the update - works great.  I suppose the "create folder" option is not possible...)

Link to comment
Share on other sites

...For example, right click on the UI and choose New->Folder.

There's that proverbial gun again, pointed at my head.  Sorry, forest for the trees...

I thought of an event handler first, but never having done that outside of a GUI I created myself, I probably imagine it to be worse than it is. :)

Link to comment
Share on other sites

  • 1 month later...

I started playing with this, and I have a question. How do you make the FileSelectFolder2 window resizable? I get the double ended arrow when I hover over the lower right corner, and the bottom of the window, but clicking and dragging doesn't affect the size, it's frozen at max.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

trancexx does not do anything to make the window resizable. The window is created with IFileDialog.Show (inherited from IModalWindow). This method creates a modal dialogbox which is resizable by default. When I run the example in the first post the window is resizable. I'm on Win 7 64 bit. Isn't the window resizable when you run this example?

Link to comment
Share on other sites

 I get the double ended arrow when I hover over the lower right corner, and the bottom of the window, but clicking and dragging doesn't affect the size, it's frozen at max.

 

trancexx does not do anything to make the window resizable. The window is created with IFileDialog.Show (inherited from IModalWindow). This method creates a modal dialogbox which is resizable by default. When I run the example in the first post the window is resizable. I'm on Win 7 64 bit. Isn't the window resizable when you run this example?

On the computer I tested this on, it wasn't resizable. I just tested it on another computer and it can be resized. Weird.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

  • 2 weeks later...

This is awesome. Thanks so much trancexx  :thumbsup: 
Now one could almost be totally unaware that they are using a AutoIT built application. I like how "polished" things are becoming, no thanks to people like your self.

Maybe someday in the not so distant future AutoIT can be remembered as not just a hacker/virus building tool and as something that great applications are be built from.

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