Hi,
Is there a way to retrieve files from a folder (say A_WinDir\Fonts), then put the contents of the folder into a DropDownList?
Thanks!
Retrieve folder contents, then put them into a DDL. Topic is solved
Re: Retrieve folder contents, then put them into a DDL.
Example:
Code: Select all
Loop, Files, % A_WinDir . "\Fonts\*.*"
fileList .= A_LoopFileName . "|"
Gui, Add, DropDownList, gSelectedFile vFileChoice, % RTrim(fileList, "|")
Gui, Show
return
SelectedFile:
Gui, Submit, NoHide
MsgBox, 4096, you selected, % FileChoice
return
Re: Retrieve folder contents, then put them into a DDL.
It works!
Incorporating it into my AHK script...
Incorporating it into my AHK script...
- flyingDman
- Posts: 2821
- Joined: 29 Sep 2013, 19:01
Re: Retrieve folder contents, then put them into a DDL.
I think that a DDL is somewhat of a dud when you have many items to list. It's not searchable so you have to scroll. A small listview is much more versatile and can be implemented together with a search box with just a few more lines of code:
Code: Select all
gui, add, text,x8, search:
gui, add, edit, x+10 y3 w105 gsearch vneedle
gui, add, listview, x8 y+2 w150 r5 vMyLV gpick -hdr,Files
gui, show
search:
gui, submit, nohide
lV_delete()
loop, files, % a_windir "\Fonts\*.*"
if (instr(A_LoopFileName, needle))
lv_add("", A_LoopFileName)
LV_ModifyCol(1,130)
return
pick:
lv_GetText(item, A_EventInfo,1)
msgbox % item
return
14.3 & 1.3.7
Re: Retrieve folder contents, then put them into a DDL.
Ok.
I'll try your suggestion now.
I'll try your suggestion now.
Re: Retrieve folder contents, then put them into a DDL.
You might want to check out @teadrinker's searchable ComboBox (post).flyingDman wrote: ↑09 Aug 2022, 20:22I think that a DDL is somewhat of a dud when you have many items to list. It's not searchable so you have to scroll.
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)
- flyingDman
- Posts: 2821
- Joined: 29 Sep 2013, 19:01
Re: Retrieve folder contents, then put them into a DDL.
@iPhilip Thanks. That's very clever but it does not match the versatility of the listview. After a small change in my script above, clicking on an item return the full path.
Code: Select all
gui, add, text,x8, search:
gui, add, edit, x+10 y3 w105 gsearch vneedle
gui, add, listview, x8 y+2 w150 r5 vMyLV gpick -hdr,Files|Path
gui, show
LV_ModifyCol(2,0)
search:
gui, submit, nohide
lV_delete()
loop, files, % a_windir "\Fonts\*.*"
if (instr(A_LoopFileName, needle))
lv_add("", A_LoopFileName,A_LoopFileFullPath)
LV_ModifyCol(1,130)
return
pick:
lv_GetText(item, A_EventInfo,2)
msgbox % item
return
14.3 & 1.3.7