FileSelectFile() : Supports multi-line filter

Post your working scripts, libraries and tools for AHK v1.1 and older
Peaceful
Posts: 28
Joined: 20 Mar 2017, 06:28

Re: FileSelectFile() : Supports multi-line filter

29 Sep 2020, 21:34

same as foobar2000 and Media Player

foobar2000 screenshot:
Image

So many apps are this style.
That's perfect.
User avatar
SKAN
Posts: 1551
Joined: 29 Sep 2013, 16:58

Re: FileSelectFile() : Supports multi-line filter

30 Sep 2020, 03:58

gwarble wrote:
29 Sep 2020, 14:53
Thanks

Well I wouldn't want you to put an ugly trick in your elegant function, but if you came up with one I'd probably use it, as we treat no extension just like any other extension usually driven by the machine tool's software and/or interface (ethernet or memory card) requirements. Its surely not desperately needed as I've gotten by without it for this long :)
I've been trying hard.. No joy.. yet. :(

If I was in such situation, I might work around as follows
1) make a list of files without extension
2) create a temp folder
3) create shortcuts for each file.
4) show dialog for the temp folder
5) delete temp folder after dialog is dismissed.

But instead of all this trouble, It would be better to create a custom TreeView based UI :(
User avatar
SKAN
Posts: 1551
Joined: 29 Sep 2013, 16:58

FileSelectFile() : v0.72

30 Sep 2020, 04:02

Code updated:

0.72A_LastError will contain the index of selected Filter. (Valid only if ErrorLevel is 0)

 
Demo script:
 

Code: Select all

#NoEnv
#SingleInstance, Force

Filter := "|Run with AutoHotkeyA32.exe (*.ahk)|Run with AutoHotkeyU32.exe (*.ahk)||Run with AutoHotkeyU64.exe (*.ahk)"
Selection := ["AutoHotkeyA32.exe", "AutoHotkeyU32.exe", "AutoHotkeyU64.exe"]

File := FileSelectFile( 1,,"Select script & interpreter", Filter)
If ! (ErrorLevel)
   MsgBox,,User choice, % "Run`n" . File . "`nwith`n" . Selection[A_LastError]

; Paste FileSelectFile() below
 
Image
My Scripts and Functions: V1  V2
User avatar
gwarble
Posts: 524
Joined: 30 Sep 2013, 15:01

Re: FileSelectFile() : Supports multi-line filter

30 Sep 2020, 14:20

SKAN wrote:
30 Sep 2020, 03:58
But instead of all this trouble, It would be better to create a custom TreeView based UI :(
Thanks for looking in to it...

using different directories and shortcuts would be too cumbersome and problematic of a solution but I like the creative thinking... because most of the files we deal with are either named in the format "O1234" or "O2345 (COMMENT)" and your filtering allows for more than just extensions, I'm starting with something like:

All Documents (*.*)|NC Code (*0;*1;*2;*3;*4;*5;*6;*7;*8;*9;*)*)|AutoHotkey (*.ahk)|Heidenhein (*.H)

Which catches all files that end with a number or a right-parenthesis.
EitherMouse - Multiple mice, individual settings . . . . www.EitherMouse.com . . . . forum . . . .
User avatar
SKAN
Posts: 1551
Joined: 29 Sep 2013, 16:58

Re: FileSelectFile() : Supports multi-line filter

30 Sep 2020, 15:12

gwarble wrote:
30 Sep 2020, 14:20
All Documents (*.*)|NC Code (*0;*1;*2;*3;*4;*5;*6;*7;*8;*9;*)*)|AutoHotkey (*.ahk)|Heidenhein (*.H)
Nice! But if I make copies of files in explorer, the file copies end with Copy (2) .. Copy(3) and so on.
I just realized the extensions cannot have open parenthesis in it, as I split the filter line at the last occurring (.
User avatar
gwarble
Posts: 524
Joined: 30 Sep 2013, 15:01

Re: FileSelectFile() : Supports multi-line filter

30 Sep 2020, 15:35

ah yes that explains why "*)" wasn't working without that last *
EitherMouse - Multiple mice, individual settings . . . . www.EitherMouse.com . . . . forum . . . .
hasantr
Posts: 933
Joined: 05 Apr 2016, 14:18
Location: İstanbul

Re: FileSelectFile() : Supports multi-line filter

07 Dec 2020, 17:46

Hi @SKAN Our job is very easy with your functions. Thank you.

How can I use this function to select folders? The built-in FileSelectFolder isn't powerful enough.
robodesign
Posts: 934
Joined: 30 Sep 2017, 03:59
Location: Romania
Contact:

Re: FileSelectFile() : Supports multi-line filter

07 Dec 2020, 18:53

hasantr wrote:
07 Dec 2020, 17:46
Hi @SKAN Our job is very easy with your functions. Thank you.

How can I use this function to select folders? The built-in FileSelectFolder isn't powerful enough.
This function offers the ability...
https://github.com/marius-sucan/other-small-AHK-scripts/blob/master/select-folder-extended.ahk

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
hasantr
Posts: 933
Joined: 05 Apr 2016, 14:18
Location: İstanbul

Re: FileSelectFile() : Supports multi-line filter

07 Dec 2020, 19:20

robodesign wrote:
07 Dec 2020, 18:53
hasantr wrote:
07 Dec 2020, 17:46
Hi @SKAN Our job is very easy with your functions. Thank you.

How can I use this function to select folders? The built-in FileSelectFolder isn't powerful enough.
This function offers the ability...
https://github.com/marius-sucan/other-small-AHK-scripts/blob/master/select-folder-extended.ahk

Best regards, Marius.
This is great. Thank you so much.
hasantr
Posts: 933
Joined: 05 Apr 2016, 14:18
Location: İstanbul

Re: FileSelectFile() : Supports multi-line filter

04 Jan 2021, 12:53

I can't filter lnk files. Shortcut files always appear. Is there any way to hide shortcut files?
nu10e8368NrrfXGQKvwn
Posts: 6
Joined: 01 Mar 2021, 05:43

Re: FileSelectFile() : Supports multi-line filter

05 Mar 2021, 10:20

Hi, @SKAN, I tried this function but I get a strange result. Here's the code I used:

Code: Select all

#NoEnv							; Recommended for performance and compatibility with future AutoHotkey releases
SendMode Input					; Recommended for new scripts due to its superior speed and reliability
#SingleInstance, Force			; Allow only one running instance of script
#Warn All, MsgBox				; Enable warnings to assist with detecting common errors

path := FileSelectFile("S16|||" . WinExist("A"), "C:\Downloads\AutoHotkey Test Script.ahk","Duplica File","|Tutti i file (*.*)")
if (path != "")
{
	msgbox % path
}

return

FileSelectFile( Options:="", RootDir:="", Title:="", Filter:="" ) {   ;   v0.72 by SKAN on D39R/D39U
...
}
I type "1" in the select window and I get this:
---------------------------
AutoHotkey Test Script.ahk
---------------------------
C:\Downloads\1
Script.ahk
---------------------------
OK
---------------------------
"123.abc" gives this:
---------------------------
AutoHotkey Test Script.ahk
---------------------------
C:\Downloads\123.abc
t.ahk
---------------------------
OK
---------------------------
:?:
User avatar
SKAN
Posts: 1551
Joined: 29 Sep 2013, 16:58

Re: FileSelectFile() : Supports multi-line filter

08 Mar 2021, 17:24

nu10e8368NrrfXGQKvwn wrote:
08 Mar 2021, 16:09
@SKAN

bump?
 

I'm able to reproduce the said glitch.
Can you please help me to fix it?
If you may...

Please replace line 60
from

Code: Select all

    OutputVar .= Line . "`n",  f += ( (StrLen(Line)+1) * x )
to

Code: Select all

    OutputVar .= Line . "`n",  f += ( (StrLen(Line)+( o="m" ? 1 : 0 ) ) * x )
nu10e8368NrrfXGQKvwn
Posts: 6
Joined: 01 Mar 2021, 05:43

Re: FileSelectFile() : Supports multi-line filter

09 Mar 2021, 12:16

SKAN wrote:
08 Mar 2021, 17:24
Please replace line 60
That works! Putting in "1" now gives me the correct message:
---------------------------
AutoHotkey Test Script.ahk
---------------------------
C:\Downloads\1
---------------------------
OK
---------------------------


Thanks, SKAN! :D

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 76 guests