david1337 Posted September 14, 2016 Share Posted September 14, 2016 (edited) Hey guys I hope you can get me in the right direction with this one: It's pretty easy to get a list with a specific filetype, and show it with _ArrayDisplay #include <File.au3> Local $aFileList = _FileListToArray("C:\Test\", "*.txt") _ArrayDisplay($aFileList, "Available text files") But what if I want to create a GUI with a button for every available txt file, and name each button after the txt file? Let's say I have 3 txt files in C:\Test\ file1.txt file2.txt file3.txt Should end up with a GUI with 3 buttons lined up vertically: [ file1 ] [ file2 ] [ file3 ] I hope it makes sense :-) Edited September 15, 2016 by david1337 Link to comment Share on other sites More sharing options...
InunoTaishou Posted September 14, 2016 Share Posted September 14, 2016 #include <File.au3> #include <GUIConstants.au3> #include <Array.au3> Global $aButtonIds = _FileListToArray("C:\test\", "*.*", $FLTA_FILES) Global $hGui = GUICreate("Edit Get Text", 400, 300) Global $aButtons[_ArrayDelete($aButtonIds, 0)] For $i = 0 to UBound($aButtonIds) - 1 $aButtonIds[$i] = GUICtrlCreateButton($aButtonIds[$i], 10, 10 + ($i * 30), 100, 20) Next GUISetState(@SW_SHOW, $hGui) While (True) Local $iMsg = GUIGetMsg() Switch ($iMsg) Case $GUI_EVENT_CLOSE Exit 0 Case Else For $i = 0 to UBound($aButtonIds) - 1 If ($iMsg = $aButtonIds[$i]) Then MsgBox("", "", "Button " & GUICtrlRead($aButtonIds[$i]) & " pressed") ExitLoop EndIf Next EndSwitch WEnd david1337 1 Link to comment Share on other sites More sharing options...
david1337 Posted September 15, 2016 Author Share Posted September 15, 2016 InunoTaishou, Exactly what I was looking for! Thank you so much, I will learn from your code now :-) 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