Jump to content

I want to list a bunch of files within a directory, in the GUI, How would I be able to do this?


Recommended Posts

I'm going on day 2 trying to figure this out, deciding to ask for some help. I'm trying to list files (that are clickable) within a directory in the GUI tab object, but haven't been successful.

I am able to get the list of files, which show up before the GUI is launched. I am currently using Array.au3 and File.au3 to do this. What I want is the files to appear within the tab windows of the tabbed items... if that makes sense. Any advice? Here is my code:

#include <GUIConstantsEx.au3>

#include <Array.au3>

#include <File.au3>

#include "RecFileListToArray.au3"

_Main()

Func _Main()

Local $Buyers = _ArrayDisplay("C:DropboxCentury21Client DatabaseBuyers")

; Variable is assigned to list the files and folders

GUICreate("C21 Chicago's Finest", 800, 600) ; creates window

GUICtrlCreateTab(50, 50, 700, 300)

GUICtrlCreateTabItem("Buyers")

GUICtrlCreateList((_FileListToArray($Buyers)), 50, 70, 699, 313)

EndFunc

GUISetState ()

While 1

Switch GUIGetMsg()

Case $GUI_EVENT_CLOSE

Exit

EndSwitch

WEnd

Edited by enigmaforceiv
Link to comment
Share on other sites

Hi,

Try this:

#region
#AutoIt3Wrapper_Run_Tidy=y
#AutoIt3Wrapper_Tidy_Stop_OnError=n
#endregion

#include <File.au3>
#include <Array.au3>
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Global $font = "Arial"
Global $GUI_BGC = "0xf0ffff"

$GUI = GUICreate("List folder content", 500, 200, -1, -1)
GUISetBkColor($GUI_BGC)
$list = GUICtrlCreateList("", 2, 2, 496, 150)
GUISetState(@SW_SHOW)

Opt("GUICoordMode", 3)

GUISetFont(9, 1000, 0, $font)

Sleep(5000)

$FileList = _FileListToArray("C:", "*", 2) ; get only folders with the quoted string
_ArrayDelete($FileList, 0) ; Throwing out the total folder count from the 0 index
;_ArrayDisplay($FileList)

For $folder In $FileList ; Loop over folders found.
GUICtrlSetData($list, $folder)
Next

While 1
$nMsg = GUIGetMsg()
Select
Case $nMsg = $GUI_EVENT_CLOSE
Exit
EndSelect
WEnd

link to help for _FileListToArray: http://www.autoitscript.com/autoit3/docs/libfunctions/_FileListToArray.htm

Hope it helps,

Fraser

Edited by Fraser
Link to comment
Share on other sites

Edit: Not a problem, Glad to help!

Sorry about that, i had _arraydisplay added. Find that and remove it shouldn't pop up again!

#region
#AutoIt3Wrapper_Run_Tidy=y
#AutoIt3Wrapper_Tidy_Stop_OnError=n
#endregion

#include
#include
#include
#include
#include

Global $font = "Arial"
Global $GUI_BGC = "0xf0ffff"

$GUI = GUICreate("List folder content", 500, 200, -1, -1)
GUISetBkColor($GUI_BGC)
$list = GUICtrlCreateList("", 2, 2, 496, 150)
GUISetState(@SW_SHOW)

Opt("GUICoordMode", 3)

GUISetFont(9, 1000, 0, $font)

Sleep(5000)

$FileList = _FileListToArray("C:", "*", 2) ; get only folders with the quoted string
_ArrayDelete($FileList, 0) ; Throwing out the total folder count from the 0 index
;_ArrayDisplay($FileList) <<<
For $folder In $FileList ; Loop over folders found.
GUICtrlSetData($list, $folder)
Next

While 1
$nMsg = GUIGetMsg()
Select
Case $nMsg = $GUI_EVENT_CLOSE
Exit
EndSelect
WEnd

Regards

Fraser

Edited by Fraser
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...