Sign in to follow this  
Followers 0
Matz

Directory search with checkbox

6 posts in this topic

Hi.

I'm making a backuptool and trying to add this feature...

(1)Searching for a given filetype (*.doc) in given directory (c:\). (@comspec /c dir *.doc > list.txt or something)

Thats the easy part...

(2)The hard part is to get the list.txt and List the files with checkboxes. There could be another smart way of doing part (1).

(3)Then copy the files checked...

Anyone got a tip on where to start?

Kindly Regards

Mats :P

Share this post


Link to post
Share on other sites



Tried that one.. found some posts with treeview from file.. But didnt get any ideas

Trying to do a Findnextfile, and adding to treeview list and see what comes out of it :P

Share this post


Link to post
Share on other sites

I've now come up with a code to list one type of file in a path into a gui with checkboxes...

Is there a way to extract the files checked to another file?

#include <GuiConstants.au3>
#include <file.au3>

Global $line
$line = "1"
$searchdir = "d:\"
$searchfile = "*.mp3"

RunWait(@ComSpec & ' /c DIR "' & $searchfile & '" /A-D /B /S ' & $searchfile & ' > %TEMP%\checkfiles.tmp', $searchdir, @SW_HIDE)


GUICreate("test", 500, 400, -1, -1)
GUISetState (@SW_SHOW)    

$checktree = GuiCtrlCreateTreeView(10, 10, 450, 350, $TVS_CHECKBOXES)


While 1
    
    
    $readline = FileReadLine(@TempDir & "\checkfiles.tmp", $line)
    If @error Then ExitLoop
    
    $check1 = GuiCtrlCreateTreeViewItem($readline, $checktree)
    GUICtrlSetState ($check1, $GUI_CHECKED )
    
    $line = $line + 1
    
WEnd



While 1
    $msg = GUIGetMsg()
   
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Hi,

Here it is using ListView;

;checkkkbasic.au3 0_2
#include <GuiConstants.au3>
#include <GuiListView.au3>
#include <array.au3>
#include <file.au3>
Local $ar_isChecked [1],$aArray
Global $line
$line = "1"
$searchdir = "c:\"
$s_NewDir = $searchdir & "backup"
$searchfile = "*.txt"
$timerstampS = TimerInit()
$gui = GUICreate("TEST APP!", 392, 322, -1, -1, $WS_CAPTION + $WS_POPUP + $WS_MAXIMIZEBOX + $WS_MINIMIZEBOX + $WS_SIZEBOX);+$WS_MAXIMIZE)
$Btn_Get = GUICtrlCreateButton("Get From Index 2", 150, 200, 90, 40)
;===================================================================
$listview = GUICtrlCreateListView("Column 1        ", 40, 30, 310, 149, $LVS_EX_CHECKBOXES + $LVS_EX_GRIDLINES)
;===================================================================
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_CHECKBOXES, $LVS_EX_CHECKBOXES)
RunWait(@ComSpec & ' /c DIR "' & $searchdir & '" /A-D /B  ' & $searchfile & ' > %TEMP%\checkfiles.tmp', $searchdir, @SW_HIDE)
ConsoleWrite("DOS :" & Round(TimerDiff($timerstampS)) & " mseconds " & @LF)
$timerstampS = TimerInit()
_FileReadToArray(@TempDir & "\checkfiles.tmp",$aArray)
for $i= 1 to UBound($aArray)-1
    GUICtrlCreateListViewItem($aArray[$i],$listview)
next
_GUICtrlListViewSetCheckState($listview, -1, 1)
GUISetState(@SW_SHOW, $gui)
ConsoleWrite("START :" & Round(TimerDiff($timerstampS)) & " mseconds " & @LF)
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $Btn_Get ; set up a button
            $timerstampSt = TimerInit()
            $a = 0
            ReDim $ar_isChecked [_GUICtrlListViewGetItemCount($listview) ]
            For $i = 0 To _GUICtrlListViewGetItemCount($listview) - 1
                If _GUICtrlListViewGetCheckedState($listview, $i) Then
                    $ar_isChecked [$a] = _GUICtrlListViewGetItemText($listview, $i, 0)
                    $a += 1
                EndIf
            Next
            ConsoleWrite("GET :" & Round(TimerDiff($timerstampSt)) & " mseconds " & @LF)
            If Not $a Then ReDim $ar_isChecked [1]
            If $a Then
                ReDim $ar_isChecked [$a]
                _FileWriteFromArray(@ScriptDir & "\ar_isChecked.txt", $ar_isChecked)
                RunWait("notepad " & @ScriptDir & "\ar_isChecked.txt")
;~              _ArrayDisplay($ar_isChecked, "$ar_isChecked")
                For $a = 0 To UBound($ar_isChecked) - 1
;~                  If FileExists($ar_isChecked[$a]) Then FileCopy($ar_isChecked[$a], $s_NewDir)
                Next
            EndIf
    EndSelect
WEnd
Randall

Or, below, with sorting and quick retrieval; ;

checkkk.au3

Edited by randallc

Share this post


Link to post
Share on other sites

Hi,

Here it is using ListView;

[autoit];checkkkbasic.au3 0_2

#include <GuiConstants.au3>

#include <GuiListView.au3>

#include <array.au3>

#include <file.au3>

Local $ar_isChecked [1],$aArray

Global $line

$line = "1"

$searchdir = "c:\"

$s_NewDir = $searchdir & "backup"

......

Great man!! :P Thanks alot!

------- matz -------

Share this post


Link to post
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
Sign in to follow this  
Followers 0