[GUI] FileSelect alternative - Customize / Restrict to a specific folder (15.02.2018)

Post your working scripts, libraries and tools
DigiDon
Posts: 115
Joined: 19 May 2014, 04:55

[GUI] FileSelect alternative - Customize / Restrict to a specific folder (15.02.2018)

07 Feb 2018, 07:11

Hi,

I hope this will benefit many :)

AHK GUI alternative to the FileSelectFile / FileSelectFolder dialogs
Allows more parameters/customization
Allows to restrict navigation within a specific folder
Allows selection of both files and folders


Image
Image

UPDATES last 15.02.2018 - 15h UTC+1
Spoiler


I am quite surprised I could not find such a script. I'm especially quite surprised it seems not available by Windows as standard as well :roll:
I wanted to have a GUI (TreeView and/or ListView) that allows user to naviagate folders and select a file WITHIN the specified folder.

I didn't want to apply dirty tricks to the fileselect standard dialog so I thought a complete AHK Gui could be a good solution.
So based on the ListView Main Example https://www.autohotkey.com/docs/commands/ListView.htm#Examples here is my try!

Don't hesitate to post improvements or say anything ;)

DOCUMENTATION (example at the end)

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus


FUNCTIONS AND WORKING EXAMPLE (simplier version might flicker a bit the first time it displays: please confirm)

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus


FUNCTIONS AND WORKING EXAMPLE (more complex version to try to avoid flickering the first time it show the icon view)

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

Last edited by DigiDon on 15 Feb 2018, 09:39, edited 56 times in total.
Knowledge is knowing a tomato is a fruit; wisdom is not putting it in a fruit salad. (Miles Kington)
DigiDon
Posts: 115
Joined: 19 May 2014, 04:55

Re: FileSelectFile style GUI you can restrict to a specific folder

07 Feb 2018, 12:12

UPDATE 07.02.2018 - 18h UTC+1
Function much improved !


-Have a better code structure
-Have nicer button and show "Select" button in a more adapted way
-Offer File filters
-Show folders only if select folders
-Propose folder creation (or not) via right clic
-Multi selection possible (returns the same as FileSelectFile)
-Examples improved

Would be great to improve documentation a bit though
Knowledge is knowing a tomato is a fruit; wisdom is not putting it in a fruit salad. (Miles Kington)
burque505
Posts: 213
Joined: 22 Jan 2017, 19:37

Re: FileSelectFile style GUI you can restrict to a specific folder

07 Feb 2018, 13:42

Nice script, @DigiDon. Would you take a look at my small additions? My changes are on lines 7-8 and 82-83. The reason I added them is because the button text as provided wasn't meaningful for me.
I'm trying to get a Chr(29) in the button (↔) but haven't gotten there yet.
Spoiler


EDIT: Got rid of Transform, used Chr(), running AHK_H v1.1.27.06. Using Unicode for switch view button.

Code: [Select all] [Download] GeSHi © Codebox Plus

UpArrow := Chr(24)
SwitchLeft := Chr("0x0021DA")
SwitchRight := Chr("0x0021DB")

and

Code: [Select all] [Download] GeSHi © Codebox Plus

	Gui, Add, Button, xm+10 w30 gFSPrevious, %UpArrow%
Gui, Add, Button, x+5 w30 gFSSwitchView, %SwitchLeft% %SwitchRight%


buttons.png
buttons.png (1.44 KiB) Viewed 381 times


Thanks again,
burque505
DigiDon
Posts: 115
Joined: 19 May 2014, 04:55

Re: FileSelectFile style GUI you can restrict to a specific folder

07 Feb 2018, 15:57

Thanks burque505 for the sugestion ;)

But finding perfect unicode characters is hard.
The one you suggest makes me think of On top and Enlarge.

I prefer
Image

Code: [Select all] [Download] GeSHi © Codebox Plus

Gui, Add, Button, xm+10 w20 gFSSwitchView, % Chr(0x02630)
Gui, Font, Bold
Gui, Add, Button, x+5 w30 gFSPrevious, % Chr(0x2190)


But I think I would prefer to have some nice image button with hover effect if possible, but I don't have the time to do it for now.
Knowledge is knowing a tomato is a fruit; wisdom is not putting it in a fruit salad. (Miles Kington)
DigiDon
Posts: 115
Joined: 19 May 2014, 04:55

Re: FileSelectFile style GUI you can restrict to a specific folder

08 Feb 2018, 05:46

UPDATES
08.02.2018 - 12h UTC+1
*DOCUMENTATION ADDED
*MultiSelection return value was corrected
*ABLE TO START OR NAVIGATE TO ALL DISKS
*ABLE TO RESTRICT OR NOT ABOVE NAVIGATION
*More concise usage : return Hwnd
*Refresh button
*Ability to create folder via right clic
*Ability to open the current folder in explorer via right clic
Knowledge is knowing a tomato is a fruit; wisdom is not putting it in a fruit salad. (Miles Kington)
DigiDon
Posts: 115
Joined: 19 May 2014, 04:55

Re: FileSelect GUI alternative - Customize / Restrict to a specific folder

08 Feb 2018, 10:53

UPDATE 08.02.2018 - 16h UTC+1
Bug fixed of troncated return value
New "All" param to select both files and folders
Knowledge is knowing a tomato is a fruit; wisdom is not putting it in a fruit salad. (Miles Kington)
DigiDon
Posts: 115
Joined: 19 May 2014, 04:55

Re: FileSelect GUI alternative - Customize / Restrict to a specific folder

13 Feb 2018, 09:21

MAJOR UPDATE ! ;)

13.02.2018 - 15h UTC+1
  • Navigation bar to show current folder and navigate directly via Enter
  • Much more dynamic sizing
  • Warning if user tries to go above restricted folder
  • Secondary text below listview
  • Size of GUI reduced and can be custom
  • Size of GUI has a minimum when resized
Knowledge is knowing a tomato is a fruit; wisdom is not putting it in a fruit salad. (Miles Kington)
DigiDon
Posts: 115
Joined: 19 May 2014, 04:55

Re: [GUI] FileSelect alternative - Customize / Restrict to a specific folder (14.02.2018)

14 Feb 2018, 16:55

14.02.2018 - 23h UTC+1
  • Correction: if multiselection and type folder: skip files
Knowledge is knowing a tomato is a fruit; wisdom is not putting it in a fruit salad. (Miles Kington)
burque505
Posts: 213
Joined: 22 Jan 2017, 19:37

Re: [GUI] FileSelect alternative - Customize / Restrict to a specific folder (14.02.2018)

14 Feb 2018, 17:47

Hi DigiDon, thanks for your continued work on this project. Just wanted to alert you to a couple of things.
I'm running Win7-64, AHK_L 1.1.127.07 and have tried it with AHK_H 1.1.127.06, both U64.

1) As downloaded, it won't start. At lines 337 and 435, instead of "SetTimer( "RemoveToolTip", -3000 )", I think it needs to be:

Code: [Select all] [Download] GeSHi © Codebox Plus

SetTimer, RemoveToolTip, -3000

Replacing that and running it brings up this GUI, much different than the OP's images:
SelectFiles.GUI.2.14.18.PNG
SelectFiles.GUI.2.14.18.PNG (49.01 KiB) Viewed 138 times

But upon entering a folder:
SelectFiles.2.14.18.PNG
SelectFiles.2.14.18.PNG (63.17 KiB) Viewed 138 times


Regards,
burque505
DigiDon
Posts: 115
Joined: 19 May 2014, 04:55

Re: [GUI] FileSelect alternative - Customize / Restrict to a specific folder (14.02.2018)

14 Feb 2018, 18:00

Hi burque505,

Thanks for notifying me! ;)

I already implemented it in a project and therefore am making modifications in it directly before trying to put them back on there.

Truth is I was surprized nobody complained of a problem :lol:

I'll take a proper look, will soon update.
Last edited by DigiDon on 14 Feb 2018, 18:19, edited 1 time in total.
Knowledge is knowing a tomato is a fruit; wisdom is not putting it in a fruit salad. (Miles Kington)
DigiDon
Posts: 115
Joined: 19 May 2014, 04:55

Re: [GUI] FileSelect alternative - Customize / Restrict to a specific folder (14.02.2018)

14 Feb 2018, 18:15

I've made some changes and it seems the single line WinWaitClose of the example does not work anymore because the Gui is hidden at first.
So the calling of the function has to be modified.

I'm on the same environement so it works but please confirm ;)
I've updated the OP.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

Knowledge is knowing a tomato is a fruit; wisdom is not putting it in a fruit salad. (Miles Kington)
burque505
Posts: 213
Joined: 22 Jan 2017, 19:37

Re: [GUI] FileSelect alternative - Customize / Restrict to a specific folder (14.02.2018)

15 Feb 2018, 08:26

Hi, I'm still getting exactly the same behavior, except no SetTimer error.
Screenshots still the same as my last post.
Regards,
burque505
DigiDon
Posts: 115
Joined: 19 May 2014, 04:55

Re: [GUI] FileSelect alternative - Customize / Restrict to a specific folder (14.02.2018)

15 Feb 2018, 08:36

Hi burque505,

I'm surprized.

I've tested again from the sample in this very topic and it's working fine.

Are you sure you put first the testing sample and then the function (outside autoexecute) ?
PS: just in case I switched the examples so that you choose a file in C: first.

Please try the complete example:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

Last edited by DigiDon on 15 Feb 2018, 09:08, edited 2 times in total.
Knowledge is knowing a tomato is a fruit; wisdom is not putting it in a fruit salad. (Miles Kington)
DigiDon
Posts: 115
Joined: 19 May 2014, 04:55

Re: [GUI] FileSelect alternative - Customize / Restrict to a specific folder (14.02.2018)

15 Feb 2018, 08:45

Unrelated but I've noticed there is a small bug for the icons of the drives though, I'm working on it.

And even if there shouldn't be an error I'll try to make really sure the VarSetCapacity is fine.
Last edited by DigiDon on 15 Feb 2018, 09:40, edited 1 time in total.
Knowledge is knowing a tomato is a fruit; wisdom is not putting it in a fruit salad. (Miles Kington)
DigiDon
Posts: 115
Joined: 19 May 2014, 04:55

Re: [GUI] FileSelect alternative - Customize / Restrict to a specific folder (15.02.2018)

15 Feb 2018, 09:08

Minor corrections.
15.02.2018 - 15h UTC+1
  • Correction: Icons of drives, directories and files without ext are better dealt with
  • Included the full example to the fuction
  • Moved VarSetCapacity to protect the DllCall better
Knowledge is knowing a tomato is a fruit; wisdom is not putting it in a fruit salad. (Miles Kington)
burque505
Posts: 213
Joined: 22 Jan 2017, 19:37

Re: [GUI] FileSelect alternative - Customize / Restrict to a specific folder (15.02.2018)

15 Feb 2018, 13:41

@DigiDon, looks good! Thanks. I look forward to seeing this evolve, it will be very helpful. And your RichEdit work will be too.
Regards,
burque505
DigiDon
Posts: 115
Joined: 19 May 2014, 04:55

Re: [GUI] FileSelect alternative - Customize / Restrict to a specific folder (15.02.2018)

15 Feb 2018, 14:07

OK great news ! I suppose it is better to put a full example rather than the function and separate doc.
I guess you ran the function code directly which caused the weird things.

Thanks, I hope it will be helpful indeed.

If you can please test a bit the two functions and tell me if you see flickering on the first one (try to specify sizes if you can).
Tell me if you notice something else.
Knowledge is knowing a tomato is a fruit; wisdom is not putting it in a fruit salad. (Miles Kington)

Return to “Scripts and Functions”

Who is online

Users browsing this forum: just me and 22 guests