billgatetlhai Posted May 28, 2009 Share Posted May 28, 2009 (edited) I want to list all files in C onto a listbox or listview. I tried this code: #include<file.au3> #include<array.au3> #include<ListViewConstants.au3> #include<GuiListView.au3> ... Run("C:\WINDOWS\system32\cmd.exe" ) Run(@ComSpec & " /c dir " & "C:\*.* /s /b /a-d > Filec.log {ENTER}", "", @SW_HIDE) Run(@ComSpec & " /c dir " & "D:\*.* /s /b /a-d > Filed.log {ENTER}", "", @SW_HIDE) $ln=_FileCountLines("filec.log") Dim $a [$ln] [1] _FileReadToArray("Filec.log", $a) $l2=GUICtrlCreateListView("", 5, 325, 500, 70) _GUICtrlListView_BeginUpdate(-1) _GUICtrlListView_Addarray(-1, $a) _GUICtrlListView_EndUpdate(-1) But it cannot work. There is an error in the file "GUIListView.au3" Who can help me solve my task. Edited May 28, 2009 by billgatetlhai Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted May 28, 2009 Moderators Share Posted May 28, 2009 I want to list all files in C onto a listbox or listview. I tried this code: #include<file.au3> #include<array.au3> #include<ListViewConstants.au3> #include<GuiListView.au3> ... Run("C:\WINDOWS\system32\cmd.exe" ) Run(@ComSpec & " /c dir " & "C:\*.* /s /b /a-d > Filec.log {ENTER}", "", @SW_HIDE) Run(@ComSpec & " /c dir " & "D:\*.* /s /b /a-d > Filed.log {ENTER}", "", @SW_HIDE) $ln=_FileCountLines("filec.log") Dim $a [$ln] [1] _FileReadToArray("Filec.log", $a) $l2=GUICtrlCreateListView("", 5, 325, 500, 70) _GUICtrlListView_BeginUpdate(-1) _GUICtrlListView_Addarray(-1, $a) _GUICtrlListView_EndUpdate(-1) But it cannot work. There is an error in the file "GUIListView.au3" Who can help me solve my task.The error is not in GUIListView.au3, it's in that code!! Read the help file on how to use the functions properly before posting in the forum for support with something that just won't work. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
DCCD Posted May 28, 2009 Share Posted May 28, 2009 _FileListToArray #Include <File.au3> #Include <Array.au3> $FileList=_FileListToArray(@HomeDrive) If @Error=1 Then MsgBox (0,"","No Files\Folders Found.") Exit EndIf _ArrayDisplay($FileList,"$FileList") [u][font=Arial Black]M[/font]y Blog, AVSS Parts[/u][font=Arial Black]Else[/font][font=Arial Black]L[/font]ibya Linux Users Group Link to comment Share on other sites More sharing options...
Danny35d Posted May 28, 2009 Share Posted May 28, 2009 Look at the help file for _GUICtrlListBox_Dir() function. Below is the help file example modified a little bit.#include <GUIListBox.au3> #include <GuiConstantsEx.au3> #include <Constants.au3> Opt('MustDeclareVars', 1) $Debug_LB = False ; Check ClassName being passed to ListBox functions, set to True and use a handle to another control to see it work _Main() Func _Main() Local $hListBox ; Create GUI GUICreate("List Box Dir", 400, 296) $hListBox = GUICtrlCreateList("", 2, 2, 396, 296) GUISetState() ; Add files _GUICtrlListBox_BeginUpdate($hListBox) _GUICtrlListBox_ResetContent($hListBox) _GUICtrlListBox_InitStorage($hListBox, 100, 4096) _GUICtrlListBox_Dir($hListBox, "C:\*.*", $DDL_HIDDEN + $DDL_SYSTEM) _GUICtrlListBox_EndUpdate($hListBox) ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>_Main AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line 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