Everything AutoHotKey example

Plug-in and third party software discussion.
Post Reply
NotNull
Posts: 5261
Joined: Wed May 24, 2017 9:22 pm

Everything AutoHotKey example

Post by NotNull »

I was trying to see how far I could get using the SDK in AutoHotKey.

Further than I expected, but could not pass a Everything_GetResultSize hurdle: what type of struct is being used here? And how to translate that to AHK? Tried several syntaxes, but obviously all non working. Could not even get an error code (getlasterror)
Left it as-is in the following working script:

Code: Select all


;	Init
	EverythingDll := "Everything64.dll"
	EverythingLib := DllCall("LoadLibrary", "Str", A_ScriptDir . "\" . EverythingDll, "Ptr")


;	Set Search
	DllCall(EverythingDll . "\Everything_SetSearch", "Str", "exact:everything64.exe")


;	Execute Search and wait till done
	DllCall(EverythingDll . "\Everything_Query", "Int", True)


;	Parse results
 	Loop % DllCall(EverythingDll . "\Everything_GetNumResults", "UInt")
	{
		MsgBox %   DllCall(EverythingDll . "\Everything_GetResultFileName", "UInt", A_Index - 1, "Str") . "`n" 
	.	"Path: " . DllCall(EverythingDll . "\Everything_GetResultPath", "UInt", A_Index - 1, "Str") . "`n" 
	.  "Size: " . DllCall(EverythingDll . "\Everything_GetResultSize", "UInt", A_Index - 1, "UInt", &SIZE)
	}


;	Cleanup
	DllCall(EverythingDll . "\Everything_Reset")
	DllCall("FreeLibrary", "Ptr", EverythingLib)

void
Developer
Posts: 15352
Joined: Fri Oct 16, 2009 11:31 pm

Re: Everything AutoHotKey example

Post by void »

From looking at AHK examples:

Code: Select all

DllCall("QueryPerformanceCounter", "Int64*", CounterBefore)
Sleep 1000
DllCall("QueryPerformanceCounter", "Int64*", CounterAfter)
MsgBox % "Elapsed QPC time is " . CounterAfter - CounterBefore

The Everything_GetResultSize call should look like:

Code: Select all

DllCall(EverythingDll . "\Everything_GetResultSize", "UInt", A_Index - 1, "UInt64*", SIZE)

Then print the size with:

Code: Select all

MsgBox % "Size: " . SIZE

Change:

Code: Select all

		MsgBox %   DllCall(EverythingDll . "\Everything_GetResultFileName", "UInt", A_Index - 1, "Str") . "`n" 
	.	"Path: " . DllCall(EverythingDll . "\Everything_GetResultPath", "UInt", A_Index - 1, "Str") . "`n" 
	.  "Size: " . DllCall(EverythingDll . "\Everything_GetResultSize", "UInt", A_Index - 1, "UInt", &SIZE)
to:

Code: Select all

ResultNameSize = 260
ResultPathSize = 260
VarSetCapacity(ResultName, ResultNameSize)
VarSetCapacity(ResultPath, ResultPathSize)

...

	DllCall(EverythingDll . "\Everything_GetResultFileNameW", "UInt", A_Index - 1, "Str", ResultName)
	DllCall(EverythingDll . "\Everything_GetResultFilePathW", "UInt", A_Index - 1, "Str", ResultPath)
	DllCall(EverythingDll . "\Everything_GetResultSize", "UInt", A_Index - 1, "UInt64*", ResultSize)

	MsgBox %   ResultName . "`n" . "Path: " . ResultPath . "`n" .  "Size: " . ResultSize
Use Everything_GetResultFileNameW instead of Everything_GetResultFileName (I assume AHK works with Unicode)
Use Everything_GetResultFilePathW instead of Everything_GetResultFilePath (I assume AHK works with Unicode)

That should get you some result details, from there you can check if each DllCall call succeeds (returns non-zero)
Use Everything_GetResultFullPathNameW for the full path and filename.



AHK DllCall:
https://documentation.help/AHK_H-2.0/DllCall.htm

How to obtain textual contents from a window:
https://stackoverflow.com/questions/18052879/how-to-obtain-textual-contents-from-a-window
Post Reply