@ Guest
Thank you for the link, I've had a look into it and admit it's very clearly commented and, as such, "accessible", and thus could be a realistic approach to do an individual adaptation. But I have a mix of questions/considerations:
First: What about speed and robustness, etc.? Voidtools "Everything" has got a name that almost defies googling it, the name put naked into the search field at least, but is an incredibly stable and mature software with which all sorts of very complicated searches (i.e. searches that do their best to reduce otherwise "endless" hit tables), incl. regex and all sorts of in- and exclusions, just by varying the search string (the only problem being that "you" never remember the needed search string combination if you do not need those on a regular basis); I suppose the corresponding AHK script (which also accesses the MFT table for speed) is not (i.e. cannot be) as elaborate as the powerful Voidtools query tool, and what about index building in the AHK script, when in "Everything" even that problem is resolved in a way you cannot probably do any better?
Second, and implicit above, "you" would probably need to write lots of additional code to bring it even near the powerfulness of "Everything", since in AHK, some functionality is not implemented yet. For example, regex is possible for window identification, but not in file loops, so I had to write recursive functions for doing "elaborate" file identification (which work well, thanks to the incredible help got here), in order to have the script decide correctly if a given file is to be included into the list it's building up or not, instead of just doing a (in direct comparison incredibly simple) regex "include it: yes/no code line". (I do file naming / "tagging" by "hierarchical" strings at the beginning of my main files, in my main directory, and then identically-named subfolders for "normally"-named "secondary" and "tertiary" files, so regex in file loops would be very welcome, but I can apply now recursion instead, I'm not complaining.)
Thus, I fear that the AHK-all solution, as it is at least, would give lesser results; this being said just by very quickly browsing the code, so my assumption may be very injust.
_______________
@ Fee
Thank you very much for your kind explanations; in fact, from your link, I hadn't grasped comspec already. I know the concept of redirection, and I also know that double quotes must be escaped by double quotes, but have got quite some difficulties with those cases in real life, lots of fumbling and trial-and-error.
I happily confirm that your new script works fine (correct hit table in the msgbox), but your previous code persists in NOT working, my scrutinizing it again and again doing no help. Here are both again, with my paths:
Code: Select all
/*
; works fine, redirection into the file, then the list in msgbox:
output_path:=a_scriptdir "\es_output_temp.txt"
FileDelete,% output_path
searchvar:="autoexec"
RunWait, % comspec " /c c:\Programme\Everything\es.exe """ searchvar """ > """ output_path "",,hide
FileRead,output,% output_path
MsgBox % output
*/
; redirection does NOT work, additional double quotes do not seem to help (of course, I may have left out the precise variant that would have worked):
searchvar := "autoexec"
RunWait, % comspec " /c c:\Programme\Everything\es.exe " searchvar " | clip",,hide
MsgBox % clipboard
And in spite of the brilliant solution below, giving me the full power of "Everything", I continue being very interested in the solution of this mystery, since it's obviously of importance for other such program calls, too.
_______________
@ querty:
Absolutely incredible help, thank you a thousand times! (Well, to be honest, I would have said that to Fee already and instead, had his codeline done the wanted redirect and thus you had probably not stepped in. I have not digged into it, but, as said, strongly believe that the IPC your solution gives me now access too, allows for realizing much more powerful searches than the command-window solution, with its probably sub-set-only search facilities (which I deduct from the above-linked help page, listing what seems to be a subset only).)
Thus, to put this straight for other NON-programmers, what's to do to make your brilliant solution work (and I've got one question, too):
Code: Select all
; I unzipped the SDK, then put a copy of the (in my case) Everything32.dll into my AHK folder, now with:
C:\Programme\AHK\Everything32.dll
; _______________
; from the key assignments in my only and main script C:\Programme\AHK\1.ahk :
$!F9::
searchby_voidtools_everything()
return
; _______________
; your fantastic script as a function in the regular (i.e. non-autoexecute) section of my main (and unique) script
; c:\AHK\ahk.exe, with my adaptation (inputbox for search, and all results listed in ONE var):
searchby_voidtools_everything()
{ ; begin of function : these indicators, also with outer loops, etc., spare me too much indentation (overflowing lines)
inputbox, eingabe, Search by Voidtools Everything :,,, 300, 120
if eingabe = ; German for "input"; I try to avoid English var names that could probably be or become program invariants or such
exit
resultlist = ; initialization not needed, just for clarity
EverythingDll := "Everything" . (A_PtrSize == 8 ? "64" : "32") . ".dll"
EverythingMod := DllCall("LoadLibrary", "Str", A_ScriptDir . "\" . EverythingDll, "Ptr")
DllCall(EverythingDll . "\Everything_SetSearch", "Str", eingabe) ; changed to searchvar "eingabe"
DllCall(EverythingDll . "\Everything_Query", "Int", True)
Loop % DllCall(EverythingDll . "\Everything_GetNumResults", "UInt")
; just replaced: _MsgBox %_ (which gives the hits one by one) by: _resultlist .= "`n" ._ :
resultlist .= "`n" . DllCall(EverythingDll . "\Everything_GetResultFileName", "UInt", A_Index - 1, "Str") . " [" . DllCall(EverythingDll . "\Everything_GetResultPath", "UInt", A_Index - 1, "Str") . "]"
DllCall(EverythingDll . "\Everything_Reset")
DllCall("FreeLibrary", "Ptr", EverythingMod)
stringtrimleft, resultlist, resultlist, 1 ; the very first "`n"
msgbox, % resultlist ; gives hit list, in the form delivered by your script (will try to adapt to my specific needs)
; or then, return, resultlist in order to process it further
} ; end of function
My question being, you do a loop of subsequent dllcalls which (the dllcalls) give the results one-by-one, and I build up the full list ("hit table") within the loop. Did you do that in order to show me the results one-by-one, or is this necessary here? I'm asking since Free's (second, correctly-redirecting) script comes without a loop; this being said, it's also obvious that there, all the work is done behind the scenes, so your loop is probably necessary and just shows WHAT's done behind the scenes in the cmd.exe solution.