Matz Posted August 30, 2006 Share Posted August 30, 2006 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 Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted August 30, 2006 Moderators Share Posted August 30, 2006 Sure:http://www.autoitscript.com/forum/index.ph...highlite=BackUp 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...
Matz Posted August 30, 2006 Author Share Posted August 30, 2006 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 Link to comment Share on other sites More sharing options...
Matz Posted August 30, 2006 Author Share Posted August 30, 2006 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? expandcollapse popup#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 Link to comment Share on other sites More sharing options...
randallc Posted August 30, 2006 Share Posted August 30, 2006 (edited) Hi, Here it is using ListView; expandcollapse popup;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 WEndRandall Or, below, with sorting and quick retrieval; ;checkkk.au3 Edited August 31, 2006 by randallc ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW Link to comment Share on other sites More sharing options...
Matz Posted August 31, 2006 Author Share Posted August 31, 2006 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!! Thanks alot! ------- matz ------- 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