I've been using tFind for a while, here's my script:
Code:
;__________________________
; \____K - tFindGUI_____/
; Coded by MsgBox. Last Edit:- 08/02/09
; This script is only for systems where the filesystem is NTFS. It is a front
; end for "TFind - NTFS Disk Searcher" -- http://deadnode.org/sw/tfind/
; which is a VERY VERY FAST command line NTFS MFT (Master File Table) search tool.
;
; To use, download tFind: http://cdn.deadnode.org/tfind32.zip
; and place tFind.exe in %SYSTEMROOT%\System32 folder or any directory in your PATH.
#SingleInstance Force
SetBatchLines -1
; This is needed for (my!) Windows Vista. The drawback is that all files and folders
; opened with K - tFindGUI will be run in Admin mode! -- Remove if not needed.
if not A_IsAdmin
{
DllCall("shell32\ShellExecuteA", uint, 0, str, "RunAs", str, A_AhkPath
, str, """" . A_ScriptFullPath . """", str, A_WorkingDir, int, 1)
ExitApp
}
DriveGet allDrives, list, fixed ; Get drive list
Loop Parse, allDrives ; Extract all NTFS drives
{
l := A_LoopField
DriveGet thisDrive, FS, %l%:
If thisDrive = ntfs
{
If !firstDrive ; First drive found (usually C:)
firstDrive := l
ntfsDrives = %ntfsDrives% %l%
}
}
progName = K - tFindGui
progNameSB = %progName% - Click status bar to copy files full path.
driveShow = Available NTFS drives: %ntfsDrives%
Gui Margin, 5, 5
Gui Add, GroupBox, w300 h70
Gui Add, Text, xs+10 ys23, Drive:
Gui Add, Text, x+63 , Find this:
Gui Add, CheckBox, x+10 vpartialMatch, &Partial match
Gui Add, Button, x+18 ys+15 h20 gsHelp, &Help
Gui Add, Button, x+50 yp-9 w232 h25 vss Disabled, %driveShow%
Gui Add, Text, yp+50 w130 vnof, Files found: 0
Gui Add, Text, x+10 w120 vst, Start time: 00:00:00
Gui Add, Edit, xs+10 ys+40 w70 vfDrive Uppercase, %firstDrive%
Gui Add, Edit, x+20 w150 vfQuery
Gui Add, Button, x+5 h20 gGetResults Default, &Find
Gui Add, Text, x+50 yp+2 w120 vtt, Total time: 0
Gui Add, Text, x+21 w120 vet, End time: 00:00:00
Gui Add, ListView, xm w700 r15 gopenFolder AltSubmit, Result|File|Ext|Size|Path
LV_ModifyCol(1, 0)
LV_ModifyCol(2, 200)
LV_ModifyCol(3, 45)
LV_ModifyCol(4, 60)
LV_ModifyCol(5, 370)
Gui Add, StatusBar, gcopyPath, %progNameSB%
Gui Show,, %progName%
GuiControl focus, edit2
Return
fillInfo:
GuiControl,, nof, Files found: %Cnt%
GuiControl,, st, Start time: %startTime%
GuiControl,, tt, Total time: %totalSpeed% %sSeconds%
GuiControl,, et, End time: %endTime%
Return
GetResults:
Gui Submit, NoHide
If !fQuery
{
MsgBox,, %progName%, No query entered.
Return
}
If partialMatch
fQuery = *%fQuery%*
If !fDrive
cmdInput = "%fQuery%" %ntfsDrives% ; Bugfix. If drive letter is omitted (search all),
Else ; tFind produces "Unable to access volume '\\.'"
cmdInput = "%fQuery%" %fDrive% ; along with the results.
GuiControl,, ss, Searching.....
CMDin := "cmd /c tFind " . cmdInput
LV_Delete()
FormatTime startTime,,H:mm:ss
startSpeed := A_Now
CMDret_Stream(CMDin)
LV_ModifyCol(1 ,"Sort")
FormatTime endTime,,H:mm:ss
endSpeed := A_Now
totalSpeed := endSpeed-startSpeed
If totalSpeed < 2
sSeconds = second
Else
sSeconds = seconds
If yesRslt =
{
Cnt = 0
Gosub fillInfo
noResult = No results for "%fQuery%"
LV_Add("","" , noResult)
GuiControl,, ss, %driveShow%
Return
}
yesRslt =
GuiControl,, ss, %driveShow%
GoSub fillInfo
cnt=
Return
openFolder:
LV_GetText(fChoice,A_EventInfo)
If (A_GuiEvent = "DoubleClick") {
Menu myMenu, Add, &Open Directory, doMenu
Menu myMenu, Add, &Run File, doMenu
Menu myMenu, Add
Menu myMenu, Add, &Copy Full Path, doMenu
Menu myMenu, Show
Menu myMenu, DeleteAll ; Prevents separator lines appearing at bottom of menu.
}
If (A_GuiEvent = "Normal" || A_GuiEvent = "I") {
SB_SetText(fChoice)
}
Return
doMenu:
If ( !ThisMenuItem )
ThisMenuItem = %A_ThisMenuItem%
If (ThisMenuItem = "&Open Directory")
Run explorer `/select`, %fChoice%
If (ThisMenuItem = "&Run File")
Run %fChoice%
If (ThisMenuItem = "&Copy Full Path")
SetTimer copyPath, on
ThisMenuItem =
Return
copyPath:
If (fChoice = "Result") {
GuiControl,, ss, Nothing to copy!
SB_SetText("Please make a selection first!")
Sleep 3000
GuiControl,, ss, %driveShow%
SB_SetText(progNameSB)
Return
}
Clipboard = %fChoice%
GuiControl,, ss, Full path copied to the clipboard.
SB_SetText(fChoice " -- COPIED")
Sleep 3000
GuiControl,, ss, %driveShow%
SB_SetText(fChoice)
SetTimer copyPath, off
Return
sHelp:
MsgBox,, %progName% - Help, Drives:`nSeparate multi-drive search with a space, eg. C E`nClear drive edit box to search ALL NTFS drives.`n`nWild cards:`n? any single charactor, eg. tF??dG?i.exe`n* any charactors, eg. tFind*, *.ahk`nCan be used in combination, eg. *F?nd*`n`nPartial Match:`nChecking this box is the equivalent of using *query*`n`nPattern matching is NOT case-sensitive.`n`nDouble-clicking a found file brings up a menu offering the choice of running the file or locate and select it in Explorer.`n`nTo copy the files full path to the clipboard click the status bar.
Return
GuiEscape:
GuiClose:
ExitApp
Return
CMDret_Output(CMDout, CMDname="")
{
global yesRslt, Cnt
If (CMDout) {
Cnt++
SplitPath CMDout, fName, fPath, fExt
FileGetSize fSize, %CMDout%, K
LV_Add("", CMDout, fName, fExt, fSize, fPath)
yesRslt = 1
}
}
CMDret_Stream(CMDin, CMDname="", WorkingDir=0)
{
Global cmdretPID
tcWrk := WorkingDir=0 ? "Int" : "Str"
idltm := A_TickCount + 20
LivePos = 1
VarSetCapacity(CMDout, 1, 32)
VarSetCapacity(sui,68, 0)
VarSetCapacity(pi, 16, 0)
VarSetCapacity(pa, 12, 0)
Loop, 4 {
DllCall("RtlFillMemory", UInt,&pa+A_Index-1, UInt,1, UChar,12 >> 8*A_Index-8)
DllCall("RtlFillMemory", UInt,&pa+8+A_Index-1, UInt,1, UChar,1 >> 8*A_Index-8)
}
IF (DllCall("CreatePipe", "UInt*",hRead, "UInt*",hWrite, "UInt",&pa, "Int",0) <> 0) {
Loop, 4
DllCall("RtlFillMemory", UInt,&sui+A_Index-1, UInt,1, UChar,68 >> 8*A_Index-8)
DllCall("GetStartupInfo", "UInt", &sui)
Loop, 4 {
DllCall("RtlFillMemory", UInt,&sui+44+A_Index-1, UInt,1, UChar,257 >> 8*A_Index-8)
DllCall("RtlFillMemory", UInt,&sui+60+A_Index-1, UInt,1, UChar,hWrite >> 8*A_Index-8)
DllCall("RtlFillMemory", UInt,&sui+64+A_Index-1, UInt,1, UChar,hWrite >> 8*A_Index-8)
DllCall("RtlFillMemory", UInt,&sui+48+A_Index-1, UInt,1, UChar,0 >> 8*A_Index-8)
}
IF (DllCall("CreateProcess", Int,0, Str,CMDin, Int,0, Int,0, Int,1, "UInt",0, Int,0, tcWrk, WorkingDir, UInt,&sui, UInt,&pi) <> 0) {
Loop, 4
cmdretPID += *(&pi+8+A_Index-1) << 8*A_Index-8
Loop {
idltm2 := A_TickCount - idltm
If (idltm2 < 15) {
DllCall("Sleep", Int, 15)
Continue
}
IF (DllCall("PeekNamedPipe", "uint", hRead, "uint", 0, "uint", 0, "uint", 0, "uint*", bSize, "uint", 0 ) <> 0 ) {
Process, Exist, %cmdretPID%
IF (ErrorLevel OR bSize > 0) {
IF (bSize > 0) {
VarSetCapacity(lpBuffer, bSize+1, 0)
IF (DllCall("ReadFile", "UInt",hRead, "Str", lpBuffer, "Int",bSize, "UInt*",bRead, "Int",0) > 0) {
IF (bRead > 0) {
IF (StrLen(lpBuffer) < bRead) {
VarSetCapacity(CMcpy, bRead, 32)
bRead2 = %bRead%
Loop {
DllCall("RtlZeroMemory", "UInt", &CMcpy, Int, bRead)
NULLptr := StrLen(lpBuffer)
cpsize := bread - NULLptr
DllCall("RtlMoveMemory", "UInt", &CMcpy, "UInt", (&lpBuffer + NULLptr + 2), "Int", (cpsize - 1))
DllCall("RtlZeroMemory", "UInt", (&lpBuffer + NULLptr), Int, cpsize)
DllCall("RtlMoveMemory", "UInt", (&lpBuffer + NULLptr), "UInt", &CMcpy, "Int", cpsize)
bRead2 --
IF (StrLen(lpBuffer) > bRead2)
break
}
}
VarSetCapacity(lpBuffer, -1)
CMDout .= lpBuffer
bRead = 0
}
}
}
}
ELSE
break
}
ELSE
break
idltm := A_TickCount
LiveFound := RegExMatch(CMDout, "m)^(.*)", LiveOut, LivePos)
Sleep 100 ; kj
If (LiveFound)
SetTimer, cmdretSTR, 5
}
cmdretPID=
DllCall("CloseHandle", UInt, hWrite)
DllCall("CloseHandle", UInt, hRead)
}
}
;msgbox "%cmdout%" ; kj
StringTrimLeft, LiveRes, CMDout, %LivePos%
If LiveRes <>
Loop, Parse, LiveRes, `n
{
FileLine = %A_LoopField%
StringTrimRight, FileLine, FileLine, 1
CMDret_Output(FileLine, CMDname)
}
StringTrimLeft, CMDout, CMDout, 1
cmdretPID = 0
Return, CMDout
cmdretSTR:
SetTimer, cmdretSTR, Off
If (LivePosLast <> LiveFound) {
FileLine = %LiveOut1%
LivePos := LiveFound + StrLen(FileLine) + 1
LivePosLast := LivePos
CMDret_Output(FileLine, CMDname)
}
Return
}