Jump to content

Recommended Posts

Posted

The following code lists all files & folders in the current directory. I was thinking of creating a counter, increase it every time a tree view item is added. Then in a for loop, check each item with a IsFolder() function, but there isn't a function that I'm aware of that does that.

#include <GUIConstantsEx.au3>
#include <TreeViewConstants.au3>
#include <WindowsConstants.au3>

Local $frmMain = GUICreate("Tree View", 234, 363, -1, -1)
Local $tMain = GUICtrlCreateTreeView(0, 0, 250, 380)

$hFiles = FileFindFirstFile("*.*")
If $hFiles = -1 Then Exit

While 1
    $cFile = FileFindNextFile($hFiles)
    If @error Then ExitLoop
    GUICtrlCreateTreeViewItem($cFile, $tMain)
WEnd
FileClose($hFiles)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd
Posted (edited)

You can use the @extended macro to check whether it is a folder!

...
$cFile = FileFindNextFile($hFiles)
If @extended then ConsoleWrite("Found a dir" & @CRLF)
...

BR,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Posted

Another way would be using Function _FileListToArray_FileListToArray with its parameter.

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

  • 4 months later...
Posted

Hi

I like the code above. Simple to read and understand. Is it possible to use the list thats created in the gui so that if idouble click on the file, it then opens?

thanks

Drunken Frat-Boy Monkey Garbage

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
  • Recently Browsing   0 members

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