Everything Super Fast Search interface

Post your working scripts, libraries and tools for AHK v1.1 and older
treashunter

Everything Super Fast Search interface

07 Apr 2015, 13:48

Hi all!

Just wanted to post something i had to create for a project at work.

It utilized the Everything Search(Voidtools) command line interface to search a networked drive like...Wicked Fast.

Its a very simple script really, but i find it to work excellently for our purposes, and perhaps someone else here will find it usefull for their own implementations :)

How it works:

For my uses...it gets called from an Excel worksheet
User then searches for file, and in my case i limit it to .xls since those are what we are looking for in the end.
Also, since we run a Terminal server, i check to see if the everything.exe process is running under the specific user who launched it, and start the cmd linen interface if needed.

Then, execute the search command and export to a txt file. I then simply loop through the text file and display result list to users. whichever file they choose, will then open within Excel :D
Tada! No more slow windows file searching, haha.

Code:

Code: Select all

setbatchlines, -1
#singleinstance off

gui, Add, ListView, x2 y59 w700 h263 gResultsView vResultsView, Filename| Modified
gui, Add, Button, x475 y16 w65 h19 vButton, Search
Gui, Add, Edit, x223 y16 w230 h19 vMyedit
Gui, Add, Text, x79 y16 w144 h19 , Enter Any Part of Filename:
; Generated using SmartGUI Creator for SciTE
Gui, Show, w705 h325, File Lookup
guicontrol, focus, myedit


for process in ComObjGet("winmgmts:").ExecQuery("Select * from Win32_Process WHERE NAME = 'Everything.exe'") 
{
	var := ComVar(0x0008)
    	user := ComVar()
    	domain := ComVar()
    	process.GetOwner(user.ref, domain.ref)

	if % user[] = A_Username
	{
		goto, continuescript
	}

}


Run,f:\userfolders\md\everything\everything.exe, hide, minimize
winwaitactive, Everything
{
IfWinExist, ahk_class EVERYTHING
	WinClose ; use the window found above
}

		
return

ContinueScript:
Waitforinput:
return

Gui +OwnDialogs
#ifwinactive, File Lookup
Return::
ButtonSearch:
	gui, submit, nohide

	if(Myedit <> "")
	{
		goto ExecuteSearch
		}else{
		goto OpenDialog
	}



OpenDialog:
FileSelectFile, SelectedFile,1,F:\wpwin60\
if(SelectedFile = "")
	goto, WaitforInput

ControlGet, hwnd, hwnd, , Excel71, ahk_class XLMAIN
window := Acc_ObjectFromWindow(hwnd, -16)

Xl := window.application                			
;xlsfile := xl.ActiveWorkbook.name			
Gui, destroy
xl.Run("Loadxls", SelectedFile)	
goto, guiclose



ExecuteSearch:
LV_Delete()
stringreplace, SearchStr, myedit, %A_Space%, _, all
Runwait %comspec% /c ""F:\userfolders\md\everything\es.exe" "-s" `"%searchstr%`" "*.xls"> "F:\userfolders\md\everything\files.txt"",,hide

sleep, 100

loop, read, F:\UserFolders\md\everything\files.txt
{
	Loop, parse, A_LoopReadLine, %A_Tab%
    {
		filetime := ""
		filegettime, FileTime, %A_LoopReadLine%, c
		formattime, ModifiedDate, %filetime%, MM/dd/yyyy hh:mm tt
		r1 := substr(A_Loopfield,12)
        LV_Add("",r1,ModifiedDate)
    }
}
LV_Modifycol()


ResultsView:
try
{
if A_GuiEvent = DoubleClick
	{
		LV_GetText(Filename, A_EventInfo, 1)
		editload := "F:\wpwin60\" + Filename
		Xl := ComObjActive("Excel.Application")                 
		xlsfile := xl.ActiveWorkbook.name						
		Gui, destroy
		sleep, 100
		xl.Run("Loadxls", editload)	
		goto, guiclose
	}
}

Return
GuiClose:
runwait %comspec% /c "F:\userfolders\md\everything\Everything.exe -exit",,hide
ExitApp

return

ComVar(Type=0xC)
{
    static base := { __Get: "ComVarGet", __Set: "ComVarSet", __Delete: "ComVarDel" }
    ; Create an array of 1 VARIANT.  This method allows built-in code to take
    ; care of all conversions between VARIANT and AutoHotkey internal types.
    arr := ComObjArray(Type, 1)
    ; Lock the array and retrieve a pointer to the VARIANT.
    DllCall("oleaut32\SafeArrayAccessData", "ptr", ComObjValue(arr), "ptr*", arr_data)
    ; Store the array and an object which can be used to pass the VARIANT ByRef.
    return { ref: ComObjParameter(0x4000|Type, arr_data), _: arr, base: base }
}
ComVarGet(cv, p*) { ; Called when script accesses an unknown field.
    if p.MaxIndex() = "" ; No name/parameters, i.e. cv[]
        return cv._[0]
}
ComVarSet(cv, v, p*) { ; Called when script sets an unknown field.
    if p.MaxIndex() = "" ; No name/parameters, i.e. cv[]:=v
        return cv._[0] := v
}
ComVarDel(cv) { ; Called when the object is being freed.
    ; This must be done to allow the internal array to be freed.
    DllCall("oleaut32\SafeArrayUnaccessData", "ptr", ComObjValue(cv._))
}

Run,f:\userfolders\md\everything\everything.exe, hide, minimize
	winwaitactive, Everything
	{
	IfWinExist, ahk_class EVERYTHING
		WinClose ; use the window found above
	}
 
I'm sure any of the wizards here could probably improve on this code, but for our purposes...it works great!

Thanks to a great community for helping me to get this working in the first place :P
Guest

Re: Everything Super Fast Search interface

07 Apr 2015, 13:51

Also note...i have everything pathed for our system here, so you will need to change all paths appropriately to make it work obviously, but, that should be pretty easy for most I hope :D

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 122 guests