JohnBailey Posted January 26, 2007 Share Posted January 26, 2007 Does anyone now how to create a list (using a GUI) of the files on the desktop (or other folder. it doesn't matter)? I don't understand arrays in AutoIt or much anywhere else, so this is my best shot $FileList=_FileListToArray(@DesktopDir) $totalFileAmount = _ArrayMaxIndex($FileList, 1, 1) GuiCtrlCreateList("", 5, 190, 100, 90) Dim $avArray[$totalFileAmount], $I = 0 MsgBox(0,'Max Index Numeric value',_ArrayMaxIndex($FileList, 1, 1)) For $I = 0 to UBound( $avArray ) - 1 $avArray[$I] = GuiCtrlSetData(-1, $totalFileAmount) Next A decision is a powerful thing Link to comment Share on other sites More sharing options...
improbability_paradox Posted January 26, 2007 Share Posted January 26, 2007 (edited) you're making it more difficult on yourself that you should. Here are a few pointers the first vector of $FileList is the number of files/folders found. Basically, this means that the function _ArrayMaxIndex isn't necessary. just stating the obvious, in case you didn't know (it wasn't included in your code snippet in your first post) but before you can list the entries in a GUI, you need to create the GUI using GuiCreate. I won't show you the syntax, because I will assume that you already know it or can look it up in the helpfile. Next create a ListBox, or some other control of your choice (this part was in your code... you will want to get the handle of the control when you create it, though, so that you can create additional controls and use them all. change GuiCtrlCreateList("", 5, 190, 100, 90) to $MyList=GuiCtrlCreateList("", 5, 190, 100, 90)) Then set the data in a for-next loop. Something like this should work for you local $FileList=_FileListToArray(@DesktopDir) $MyGui=GUICreate("File List") $MyList=GuiCtrlCreateList("", 5, 190, 100, 90); I didn't adjust the coordinates... go ahead and play around with them For $I = 1 to $FileList[0] GuiCtrlSetData($MyList, $FileList[$i]) Next GUISetState(@SW_SHOW) sleep(10000);so you have time to see the GUI before the script closes This is untested, as I just wrote it in the Browser, but it should do the job Edit: Don't get me wrong, it was very resourceful of you to find the function _ArrayMaxIndex() and attempt to use it. Anyway, simpler is better. And this is much simpler. Edited January 26, 2007 by improbability_paradox Link to comment Share on other sites More sharing options...
JohnBailey Posted January 27, 2007 Author Share Posted January 27, 2007 improbability_paradox, thanks! That works great! Oh, and thanks for pointing out the "obvious." I did know about that, but if I didn't it would have drove me nuts. You're right what you wrote was not only simpler, but easier to understand. Thanks also for the encouragement about the ArrayMaxIndex. A decision is a powerful thing Link to comment Share on other sites More sharing options...
JohnBailey Posted January 27, 2007 Author Share Posted January 27, 2007 improbability_paradox, what am I doing wrong? GuiCreate("File List GUI", 400, 400) $MyGui=GUICreate("File List") $MyList=GuiCtrlCreateList("", 5, 5, 300, 90) Dim $FileList _FileReadToArray("test.txt",$FileList) For $i = 1 to $FileList[0] GuiCtrlSetData($MyList, $FileList[$i]) Next A decision is a powerful thing Link to comment Share on other sites More sharing options...
BrettF Posted January 27, 2007 Share Posted January 27, 2007 Try this: #include <File.au3> #Include <GuiList.au3> Global $FileList GUICreate("File List GUI", 400, 400) $MyGui = GUICreate("File List") $MyList = GUICtrlCreateList("", 5, 5, 300, 90) If Not _FileReadToArray("test.txt", $FileList) Then MsgBox(4096, "Error", " Error reading log to Array error:" & @error) Exit EndIf For $i = 1 To $FileList[0] _GUICtrlListAddItem($MyList, $FileList[$i]) Next Hope it helps Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! 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