; ****************************************************************** ; ndff Gui ; Feb 19, 2007 ; ; by: haichen ; ; include CmdRet_stream from Corrupt ; with modifications and/or contributions made by: ; Laszlo, shimanov, toralf, Wdb ; ; and Anchor v3.5 from Titan ; ndff.exe was found on http://ndff.hotbox.ru/en/index.html ; ****************************************************************** ; ; Usage: ; please put ndff.exe in the same dir. ; ; ****************************************************************** ; Generate list of searchable drives (fixed NTFS only). helped by skwire First_Usable_Drive = 1 DriveGet, Drive_List, List, FIXED Loop, Parse, Drive_List { DriveGet, Drive_Type, FS, %A_LoopField%: If ( Drive_Type == "NTFS" and First_Usable_Drive == 1 ) { Delim_Drive_List := A_LoopField . "||" . Delim_Drive_List First_Usable_Drive := 0 } Else If ( Drive_Type == "NTFS" ) { Delim_Drive_List := Delim_Drive_List . A_LoopField . "|" } } Gui, +Resize +LabelGui +MinSize Gui, Add, Text, x20 y44 Section, Gui, Add, Tab, x20 y20 w520 h100 vMytab,Size|Date|Advanced Gui, Add, Checkbox, xs+20 ys+15 gsizetest vSizeCheckMin, Minimum Filesize Gui, Add, DropDownList, xs+210 ys+10 w50 gsizetest vSizeTypeMin,GB|MB||KB|B Gui, Add, Edit, xs+150 ys+10 w50 gsizetest vMin, Gui, Add, UpDown, , 1 Gui, Add, Checkbox, xs+20 ys+45 gsizetest vSizeCheckMax , Maximum Filesize Gui, Add, DropDownList, xs+210 ys+40 w50 gsizetest vSizeTypeMax,GB|MB||KB|B Gui, Add, Edit, xs+150 ys+40 w50 gsizetest vMax, Gui, Add, UpDown, , 1 Gui, Add, Radio, xs+380 ys+15 vAllocatedSize, allocated Filesize Gui, Add, Radio, xs+380 ys+45 Checked vRealSize, real Filesize Gui, Tab, Advanced Gui, Add, Checkbox, xs+200 ys+30 vcasesensitiv, find casesensitiv Gui, Add, Checkbox, xs+200 ys+10 vsystemfiles, find Hidden systemfiles Gui, Add, Radio, xs+20 ys+10 gcheckonlyUnused vonlyUnused, find only unused files Gui, Add, Radio, xs+20 ys+30 gcheckUnused vUnused, find also unused files Gui, Add, Checkbox, xs+20 ys+50 vRegCheck, regular expression (a.+\.pdf) Gui, Tab, Date Gui, Add, Checkbox, xs+20 ys+15 gtimetest vnewerthanCheck, Files newer than Gui, Add, DropDownList, xs+210 ys+10 w80 gtimesearch vTimeType,Modified||Created|Accessed Gui, Add, DateTime, xs+150 ys+10 w50 gtimetest vnewerthan, Gui, Add, Checkbox, xs+20 ys+45 gtimetest volderthanCheck , Files older than ;Gui, Add, DropDownList, xs+210 ys+40 w80 glisttest vTimeType1, Modified||Created|Accessed Gui, Add, DateTime, xs+150 ys+40 w50 gtimetest volderthan, Gui, Tab Gui, Add, Text, x20 y144 Section, Gui, Add, DropDownList, xs ys w50 vDrive, %Delim_Drive_List% Gui, Add, Text, xs+55 ys+5 , Drive Gui, Add, Button, xs+340 ys w120 h20 grefresh vrefreshButton, Refresh List Gui, Add, Edit, xs ys+30 w320 h20 -WantReturn vSearch, Gui, Add, Button, xs+340 ys+30 w120 h20 Default gndff vSearchItem, Search Gui, Add, Button, xs+470 ys+30 w60 h20 gabort vAbortButton, Abort Gui, Add, ListView, xs ys+100 w530 h130 vliste gMyListView AltSubmit , Folder|Name|real Size|allocated Size|Attrib|Modificated|Created|LastAccess|Version Gui, Add, Edit, xs ys+60 w320 h20 vSearchDir, Gui, Add, Button, xs+340 ys+60 w120 h20 gssd vSearchDirItem, Show only in this Folder Gui, Add, Button, xs+470 ys+60 w60 h20 vButtonshowall gshowall , Show all Gui, Add, Edit, xs ys+251 w320 h20 ReadOnly vSearchString, %SearchString% Gui, Add, Progress, x339 ys+251 w211 h20 cBlue -Smooth vMyProgress, Gui, Add, Edit, xs ys+270 w530 h80 ReadOnly vInfo, %infostr% Gui, Add, Text, xs ys+370 vhelp1, DoubleClick opens selected file in Explorer. Gui, Show, , NDff Gui Return abort: Gui, Submit, NoHide If (cmdretPID) { Process, Close, %cmdretPID% Process, Close, ndff.exe infostr .= "`n `n....Search Aborted" GuiControl,, info, %infostr% GuiControl,, MyProgress, 100 MsgBox, Search Aborted. } Return timetest: Gui, Submit, NoHide If (( newerthanCheck = 1 ) and (olderthanCheck = 1)) If (newerthan > olderthan) MsgBox, newer than -->...<--older than. please correct! If (( newerthanCheck = 1 ) and (olderthanCheck = 0)) If (newerthan > A_Now) MsgBox, Probably you won't find files with timestamps lying in the future! If (( newerthanCheck = 0 ) and (olderthanCheck = 1)) If (olderthan > A_Now) MsgBox, Probably you won't find files with timestamps lying in the future! Gosub, timesearch Return timesearch: Gui, Submit, NoHide listadd = time = If (TimeType = "Modified") time := TTimeMod If (timetype = "created") time := TTimeCreation If (timetype = "accessed") time := TTimeLastAccess OutputDebug, %timetype% time:%time% If (( newerthanCheck = 1 ) and (olderthanCheck = 1)) If ((time >= newerthan) and (time <= olderthan)) listadd := 1 If (( newerthanCheck = 1 ) and (olderthanCheck = 0)) If ((time >= newerthan)) listadd := 1 If (( newerthanCheck = 0 ) and (olderthanCheck = 1)) If ((time <= olderthan)) listadd := 1 If (( newerthanCheck = 0 ) and (olderthanCheck = 0)) listadd := 1 OutputDebug, listadd: %listadd% Return sizetest1: Gui, Submit, NoHide KF := 1024 MF := 1048576 ;1024^2 GF := 1073741824 ;1024^3 If (SizeTypeMax = "GB") MaxSize *= GF If (SizeTypeMax = "MB") MaxSize *= MF If (SizeTypeMax = "KB") MaxSize *= KF If (SizeTypeMax = "B") MaxSize := Max If (SizeTypeMin = "GB") MinSize := Min * GF If (SizeTypeMin = "MB") MinSize *= MF If (SizeTypeMin = "KB") MinSize *= KF If (SizeTypeMin = "B") MinSize := Min ;msgbox, %maxsize% %minsize% %SizeTypeMin% %SizeTypeMax% Return sizetest: Gui, Submit, NoHide KF := 1024 MF := 1048576 ;1024^2 GF := 1073741824 ;1024^3 If (SizeTypeMax = "GB") MaxSize := Max * GF If (SizeTypeMax = "MB") MaxSize := Max * MF If (SizeTypeMax = "KB") MaxSize := Max * KF If (SizeTypeMax = "B") MaxSize := Max If (SizeTypeMin = "GB") MinSize := Min * GF If (SizeTypeMin = "MB") MinSize := Min * MF If (SizeTypeMin = "KB") MinSize := Min * KF If (SizeTypeMin = "B") MinSize := Min ;msgbox, Max%maxsize% Min%minsize% %SizeTypeMin% %SizeTypeMax% If (( SizeCheckMax = 1 ) and (SizeCheckMin = 1)) If (MinSize > MaxSize) MsgBox, bigger than -->...<-- smaller than. please correct! Gosub, Sizesearch Return Sizesearch: Gui, Submit, NoHide listadd2 = size = If (AllocatedSize = 1 ) size := bp1 Else If (realsize =1) size := bp2 If (( SizeCheckMax = 1 ) and (SizeCheckMin = 1)) If ((size <= MaxSize) and (size >= MinSize)) listadd2 :=1 If (( SizeCheckMax = 1 ) and (SizeCheckMin = 0)) If (size <= MaxSize) listadd2 :=1 If (( SizeCheckMax = 0 ) and (SizeCheckMin = 1)) If (size >= MinSize) listadd2 :=1 If (( SizeCheckMax = 0 ) and (SizeCheckMin = 0)) listadd2 :=1 ;msgbox, size%size% Max%maxsize% Min%minsize% %SizeCheckMax% %SizeCheckMin% Return refresh: Gui, Submit, NoHide OutputDebug, showall LV_Delete() Gosub, split Return showall: Gui, Submit, NoHide OutputDebug, showall LV_Delete() GuiControl,, SearchDir, Gosub, split Return ssd: Gui, Submit, NoHide OutputDebug, ssd SearchDir := "*" . SearchDir FileSelectFolder,folder,%SearchDir%,0 StringRight, LastChar, Folder, 1 If LastChar = \ StringTrimRight, Folder, Folder, 1 GuiControl,, SearchDir, %folder% Gosub, split Return split: Gui, Submit, NoHide OutputDebug, split: %CMDall% str :=CMDall LV_Delete() Loop, Parse, str, `n, `r { CMDret_Output(A_loopfield, "FillList") } GuiControl,, MyProgress, 100 Sleep 600 GuiControl,, MyProgress, 0 Return MyListView: Gui, Submit, NoHide If A_GuiEvent = DoubleClick { LV_GetText(dir,A_EventInfo) LV_GetText(filename,A_EventInfo,2) filepath := dir . "\" . filename Run, explorer `/select`, %filepath% } If A_GuiEvent = Normal { LV_GetText(dir,A_EventInfo,1) GuiControl, ,SearchDir, %dir% } Return checkonlyUnused: Gui, Submit, NoHide If A_GuiEvent = doubleClick GuiControl,,onlyUnused ,0 Return checkUnused: Gui, Submit, NoHide If A_GuiEvent = doubleClick GuiControl,,Unused ,0 Return ndff: Gui, Submit, NoHide GuiControl, ,info, searching.... LV_Delete() infostr = Re = If (regCheck=1) Re:=" -re" ; Search with regular expressions case = If (casesensitiv=1) case:=" -case" ; FSY = If (systemfiles=1) FSY:=" -fsy" ; fu = If (onlyUnused=1) fu:=" -fU" ; If (Unused=1) fu:=" -fu" ; D := " -d """ . Drive . ":""" ; -d "C:" SD := " -sd" ;Show Driveletter in Outputstring SS := " -ss -sa" ;Show real and allocated file size in bytes. ; CMDin := "ndff " . Search . Re . FSY . fu . SS . case . SD . D /* -fsystem, -fsy By default, NDFF does not show special NTFS files (such as $Quota, $Volume, etc) and files located in special NTFS directories (such as "System Volume Information", $Extend, etc.). Specifying this option enables listing of those files. -fUSED, -fU Do not list existing files, list only unused file records. Implicitly applies -funused. This option can be useful when searching for deleted files. -funused, -fu Unused MFT records are skipped by default. Specifying this option includes them in the result. -sd Show drive letter. By default, this option is disabled because all resulting files are always located on single volume. -ssize, -ss Show real file size in bytes. -salloc, -sa Show allocated file size in bytes. This is amount of storage capacity used to store corresponding file. */ CMDin := "ndff " . Search . Re . FSY . fu . SS . case . SD . D GuiControl,,Searchstring ,%CMDin% Counter = ; ProgressCounter cmdall := CMDret_Stream(CMDin, "FillList") GuiControl,, MyProgress, 100 Sleep 1200 GuiControl,, MyProgress, 0 Return GuiSize: Anchor("Mytab", "w", true) Anchor("Search", "w", true) Anchor("SearchItem", "x", true) Anchor("refreshButton", "x", true) Anchor("AbortButton", "x", true) Anchor("MyProgress", "wy", true) Anchor("searchstring", "wy", true) Anchor("Buttonshowall", "x", true) Anchor("SearchDirItem", "x", true) Anchor("SearchDir", "w", true) Anchor("liste", "wh") Anchor("help1", "wy", true) Anchor("info", "wy", true) Return GuiClose: ExitApp ;------------------------------------------------------------------ ; functions ;------------------------------------------------------------------ Anchor(c, a, r = false) { ; v3.5 - Titan static d GuiControlGet, p, Pos, %c% If !A_Gui or ErrorLevel Return i = x.w.y.h./.7.%A_GuiWidth%.%A_GuiHeight%.`n%A_Gui%:%c%= StringSplit, i, i, . d .= (n := !InStr(d, i9)) ? i9 : Loop, 4 { x := A_Index, j := i%x%, i6 += x = 3, k := !RegExMatch(a, j . "([\d.]+)", v)+ (v1 . 0), e := p%j% - i%i6% * k, d .= n ? e . i5 : "", RegExMatch(d , i9 . "(?:([\d.\-]+)/){" . x . "}", v), l .= InStr(a, j) ? j . v1 + i%i6% * k : r := r ? "Draw" : } GuiControl, Move%r%, %c%, %l% } ; ****************************************************************** ; CMDret-AHK functions by corrupt ; ; CMDret_Stream ; version 0.03 beta ; Updated: Feb 19, 2007 ; ; CMDret code modifications and/or contributions have been made by: ; Laszlo, shimanov, toralf, Wdb ; ****************************************************************** ; Usage: ; CMDin - command to execute ; CMDname - type of output to process (Optional) ; WorkingDir - full path to working directory (Optional) ; ****************************************************************** ; Known Issues: ; - If using dir be sure to specify a path (example: cmd /c dir c:\) ; or specify a working directory ; - Running 16 bit console applications may not produce output. Use ; a 32 bit application to start the 16 bit process to receive output ; ****************************************************************** ; Additional requirements: ; - Your script must also contain a CMDret_Output function ; ; CMDret_Output(CMDout, CMDname="") ; Usage: ; CMDout - each line of output returned (1 line each time) ; CMDname - type of output to process (Optional) ; ****************************************************************** ; Code Start ; ****************************************************************** 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) If (LiveFound) SetTimer, cmdretSTR, 5 } cmdretPID= DllCall("CloseHandle", UInt, hWrite) DllCall("CloseHandle", UInt, hRead) } } 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 } CMDret_Output(CMDout, CMDname="") { global infostr, cmdall, searchdir, listadd, TTimeMod , TTimeCreation, TTimeLastAccess, BP, bp1, bp2,bp3,listadd2 , MB,KB,B,counter ; This function will receive output from CMDret_Stream as it is recieved from ; the application that was executed. This will allow you to process the ; output as it is received (to add to a GUI control for example). ; The CMDname param can optionally be used for processing output differently ; from different commands. If CMDname = FillList { If CMDout <> { pos := RegExMatch(CMDout,"m`n)^[a-zA-Z]+(.*)",info) If info != { infostr := infostr . "`n" . info OutputDebug, infostr: %infostr% GuiControl,, info, %infostr% } Else { pos := RegExMatch(CMDout,"m`n)(^\d+)\s+(\d+)\s+(.*)",BP) FileGetTime, TTimeMod, %BP3%,M FileGetTime, TTimeCreation, %BP3%,C FileGetTime, TTimeLastAccess, %BP3%,A timeformat = dd.MM.yyyy HH:mm:ss FormatTime, TimeMod , %TTimeMod%, %timeformat% FormatTime, TimeCreation , %TTimeCreation%, %timeformat% FormatTime, TimeLastAccess , %TTimeLastAccess%, %timeformat% FileGetAttrib, Attrib, %BP3% FileGetVersion, FVersion, %BP3% ; FileGetSize, BP1, %BP3% ; sometimes ndff (also in DOS) shows 0 B but there are some Gosub, timesearch Gosub, sizetest KF := 1024 MF := 1048576 ;1024^2 GF := 1073741824 ;1024^3 If bp3 <> { If ((bp1 >= KF) and( bp1 < MF)) bp1 := Round(bp1 /KF,2) . " KB" Else If ((bp1 >= MF) and( bp1 < GF)) bp1 := Round(bp1 /MF,2) . " MB" Else If (bp1 >= GF) bp1 := Round(bp1 /GF,2) . " GB" Else If ( bp1 < KF) bp1 .= " B" If ((bp2 >= KF) and( bp2 < MF)) bp2 := Round(bp2 /KF,2) . " KB" Else If ((bp2 >= MF) and( bp2 < GF)) bp2 := Round(bp2 /MF,2) . " MB" Else If (bp2 >= GF) bp2 := Round(bp2 /GF,2) . " GB" Else If ( bp2 < KF) bp2 .= " B" } SplitPath, BP3, name,dir If bp3 <> If ((listadd = 1) and (listadd2 = 1)) If (searchdir = dir) { LV_Add("", dir, name, BP1,BP2,Attrib,TimeMod,TimeCreation,TimeLastAccess,FVersion) }Else If (searchdir = "") LV_Add("", dir, name, BP1,BP2,Attrib,TimeMod,TimeCreation,TimeLastAccess,FVersion) } } Counter += 1 If (Counter > 100) Counter = 1 GuiControl,, MyProgress, %Counter% } Else { } Return }