Jump to content
Sign in to follow this  
CyberSlug

Save results of Windows file search

Recommended Posts

CyberSlug

I'm annoyed that Windows does not let you save the RESULTS of a file search.

Pretty straight forward usage of ControlListView. Lots of room for enhancement such as Excel integration....

; CyberSlug - 23 March 2004
; 
; After you do a file search, this lets you copy the results at tab-delimted text

Const $title = "Search Results"
Const $notepadTitle = "Untitled - Notepad"

$RowCount = ControlListView ($title,"", "SysListView321", "GetItemCount")
$ColCount = ControlListView ($title,"", "SysListView321", "GetSubItemCount")

$results = ""
For $row = 0 to $RowCount-1
    For $col = 0 to $ColCount-1
        $results = $results & ControlListView ($title,"", "SysListView321","GetText", $row, $col) & @TAB
    Next
    $results = $results & @CRLF
Next

Run("notepad")
WinWait($notepadTitle)
ControlSetText($notepadTitle,"","Edit1", $results)

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites
Ejoc

Cool


Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs

Share this post


Link to post
Share on other sites
CyberSlug

While I'm at it, here's a viewer for the above script's output.... Try the right-click menu :) Sample file attached.

;CyberSlug - 23 March 2005
;
;Viewer for search results
;NOTE:  I do not see an easy way to read the SysHeader32 control....
; If your Windows Search results has different columns, then you would need to change the code below

#include <GUIConstants.au3>

Dim $filename = @ScriptDir & "\SampleSearchResults.txt"
If $CmdLine[0] > 0 Then $filename = $CmdLine[1]

$GUI = GUICreate("Viewer for Search Results",400, 300, -1, -1, $WS_THICKFRAME)

$listview = GUICtrlCreateListView ("Name|In Folder|Size|Type|Date Modified",0,0,400,280)
$contextMenu = GuiCtrlCreateContextMenu($listview)
$infoitem = GUICtrlCreateMenuitem ("Open containing folder...",$contextMenu)

$file = FileOpen($filename, 0)

; Check if file opened for reading OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open specified search results file...")
    Exit
EndIf
; Read in lines of text until the EOF is reached
While 1
    $line = FileReadLine($file)
    If @error = -1 Then ExitLoop
    GUICtrlCreateListViewItem(StringReplace($line,@TAB,"|"),$listview)
Wend
FileClose($file)

GUICtrlCreateContextMenu ()

GUISetState()
;;;ControlSend($GUI, "", "SysListView321", "^{NUMPADADD}");doesn't work
WinWaitActive($GUI)
Send("^{NUMPADADD}"); resizes columns to show all items fully


Do
    $msg = GUIGetMsg ()
    If $msg = $infoItem Then
        $data =  StringSplit(GuiCtrlRead(GuiCtrlRead($listview)), "|")
        If UBound($data) >= 2 Then
            Run("explorer /select," & """" & $data[2] & "\" & $data[1] & """") 
        EndIf
    EndIf
Until $msg = $GUI_EVENT_CLOSE

SampleSearchResults.txt

Edited by CyberSlug

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites
vatobeto

While I'm at it, here's a viewer for the above script's output.... Try the right-click menu :) Sample file attached.

;CyberSlug - 23 March 2005
;
;Viewer for search results
;NOTE:  I do not see an easy way to read the SysHeader32 control....
; If your Windows Search results has different columns, then you would need to change the code below

#include <GUIConstants.au3>

Dim $filename = @ScriptDir & "\SampleSearchResults.txt"
If $CmdLine[0] > 0 Then $filename = $CmdLine[1]

$GUI = GUICreate("Viewer for Search Results",400, 300, -1, -1, $WS_THICKFRAME)

$listview = GUICtrlCreateListView ("Name|In Folder|Size|Type|Date Modified",0,0,400,280)
$contextMenu = GuiCtrlCreateContextMenu($listview)
$infoitem = GUICtrlCreateMenuitem ("Open containing folder...",$contextMenu)

$file = FileOpen($filename, 0)

; Check if file opened for reading OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open specified search results file...")
    Exit
EndIf
; Read in lines of text until the EOF is reached
While 1
    $line = FileReadLine($file)
    If @error = -1 Then ExitLoop
    GUICtrlCreateListViewItem(StringReplace($line,@TAB,"|"),$listview)
Wend
FileClose($file)

GUICtrlCreateContextMenu ()

GUISetState()
;;;ControlSend($GUI, "", "SysListView321", "^{NUMPADADD}");doesn't work
WinWaitActive($GUI)
Send("^{NUMPADADD}"); resizes columns to show all items fully
Do
    $msg = GUIGetMsg ()
    If $msg = $infoItem Then
        $data =  StringSplit(GuiCtrlRead(GuiCtrlRead($listview)), "|")
        If UBound($data) >= 2 Then
            Run("explorer /select," & """" & $data[2] & "\" & $data[1] & """") 
        EndIf
    EndIf
Until $msg = $GUI_EVENT_CLOSE
I know this is a l a t e post, but just found it. I modified your viewer, to use file open dialog to locate search result file, so you're not locked into one location/filename. Good idea - always hated that inability to save the results, and I'm way too lazy to rewrite the search program. :)

vatobeto.

WindowsSearchViewer.au3

Edited by vatobeto

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  

×