Jump to content

List of files


price98
 Share

Recommended Posts

Hi,

I have different files . For example, I have to two check boxes, one for text files and another one for pdf files. If i select text file check box then list of files has to shown .  Can anyone help me ?

Thanks

#include <File.au3>


Local $aFileList
Local $hGui = GUICreate("ProgramData", 450, 300)
Local $hButton = GUICtrlCreateCheckbox("File list", 144, 32, 97, 17)
Local $hList = GUICtrlCreateList("", 10, 100, 430, 200)
GUISetState(@SW_SHOW)


While True
    $sMsg = GUIGetMsg()
    Switch $sMsg
        Case -3
            Exit
        Case $hButton
            $aFileList = _FileListToArray(@DesktopDir, "*")  ; add your path here
            For $i = 0 To UBound($aFileList) -1
                GUICtrlSetData($hList, $aFileList[$i])
            Next
    EndSwitch
    Sleep(100)
WEnd

Link to comment
Share on other sites

  • Moderators

price98,

Why hijack an unrelated thread from several years ago? Why not start a new one as I have now done for you?

And although you say you have two checkboxes,  your code has only one - which seems to work as it produces a list of files on the desktop when selected. So what exactly is your problem? Why not just add a second checkbox?

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

price98,

Look at the  _FileListToArray function in the Help file - what do you think the $sFilter parameter does?

And if you want either text or pdf files, I would use radios  - if you want either or both then stick with checkboxes.

M23

P.S. I am happy to see you get help on listing the files - but the moment you ask about downloading them you are toast - clear?

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

#include <GUIConstantsEx.au3>
#include <File.au3>

Local $aFileList
Local $hGui = GUICreate("ProgramData", 450, 300)
Local $hButton_txt = GUICtrlCreateCheckbox("File list TXT", 144, 32, 97, 17)
Local $hButton_pdf = GUICtrlCreateCheckbox("File list PDF", 144, 62, 97, 17)
Local $hList = GUICtrlCreateList("", 10, 100, 430, 200)
GUISetState(@SW_SHOW)

$aFileList = _FileListToArray(@DesktopDir, "*.*", 1)  ; add your path here

While True
    $sMsg = GUIGetMsg()
    Switch $sMsg
        Case -3
            Exit
        Case $hButton_txt, $hButton_pdf
            $want_txt = IsChecked($hButton_txt)
            $want_pdf = IsChecked($hButton_pdf)
            GUICtrlSetData($hList, '')
            If $want_txt Or $want_pdf Then
                For $i = 1 To UBound($aFileList) - 1
                    If ($want_txt And StringLower(StringRight($aFileList[$i],4)) == '.txt') Or _
                       ($want_pdf And StringLower(StringRight($aFileList[$i],4)) == '.pdf') Then
                        GUICtrlSetData($hList, $aFileList[$i])
                    EndIf
                Next
            EndIf
    EndSwitch
WEnd

Func IsChecked($control)
    Return BitAnd(GUICtrlRead($control),$GUI_CHECKED) = $GUI_CHECKED
EndFunc

 

Link to comment
Share on other sites

Little speed optimization in For/Next loop:

For $i = 1 To UBound($aFileList) - 1
    $ext = StringLower(StringRight($aFileList[$i],4))
    If ($want_txt And $ext == '.txt') Or _
       ($want_pdf And $ext == '.pdf') Then
        GUICtrlSetData($hList, $aFileList[$i])
    EndIf
Next

 

Edited by Zedna
Link to comment
Share on other sites

hi,

I do not know this is the right thread to ask this question. In Microsoft access, I created the database as shown below figure.In autoit, I have to create check boxes named as Controller,Simulator,Testing (as shown in figure). Suppose If I select testing check box then all related files to testing attribue  has to shown in database. Can anyone give any idea ?

Thanks

access.png

Edited by price98
Link to comment
Share on other sites

@price98 - Yes, Please start a new thread and add as much information as you possible can. Pictures will help as well. 

Don't forget to use the <> icon to add your code.

Kind Regards
Skeletor

"Coffee: my defense against going postal."

Microsoft Office Splash Screen | Basic Notepad Program (Beginner) | Transparent Splash Screen | Full Screen UI

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...