Plug-in and third party software discussion.
Tank Ersley
Posts: 11 Joined: Sat Aug 05, 2023 5:48 pm
Post
by Tank Ersley » Thu Dec 07, 2023 4:27 am
I want to get a list of the files that are highlighted in Everything.
I have been working on various versions of this script.
Either it hangs or it returns every file that Everything has listed (regardless of highlight).
Any advice on getting this to work would be greatly appreciated.
Code: Select all
from Everything import Query, FieldRequest, SortOrder
# Function to get paths of highlighted files
def get_highlighted_paths():
# Create a query object
q = Query(queryString="", requestedFields= FieldRequest._HighlightedPath, sortOrder=SortOrder.FilenameAscending)
# Acquire the lock
q.Acquire()
try:
# Execute the query
q.Execute()
# List to store highlighted paths
highlighted_paths = []
# Iterate over the results
for result in q:
# Access the highlighted path
highlighted_path = result._HighlightedPath
if highlighted_path is not None:
highlighted_paths.append(highlighted_path)
return highlighted_paths
finally:
# Release the lock (ensure this is done in a finally block)
q.Release()
if __name__=="__main__":
highlighted_paths = get_highlighted_paths()
# Print the result
if highlighted_paths:
print("Highlighted Paths:")
for path in highlighted_paths:
print(path)
else:
print("No highlighted paths found.")
Tank Ersley
Posts: 11 Joined: Sat Aug 05, 2023 5:48 pm
Post
by Tank Ersley » Thu Dec 07, 2023 5:34 pm
I switched to the Everything SDK to see if I can get to work for me.
Code: Select all
import ctypes
#defines
EVERYTHING_REQUEST_FILE_NAME = 0x00000001
EVERYTHING_REQUEST_PATH = 0x00000002
EVERYTHING_REQUEST_FULL_PATH_AND_FILE_NAME = 0x00000004
EVERYTHING_REQUEST_EXTENSION = 0x00000008
EVERYTHING_REQUEST_SIZE = 0x00000010
EVERYTHING_REQUEST_DATE_CREATED = 0x00000020
EVERYTHING_REQUEST_DATE_MODIFIED = 0x00000040
EVERYTHING_REQUEST_DATE_ACCESSED = 0x00000080
EVERYTHING_REQUEST_ATTRIBUTES = 0x00000100
EVERYTHING_REQUEST_FILE_LIST_FILE_NAME = 0x00000200
EVERYTHING_REQUEST_RUN_COUNT = 0x00000400
EVERYTHING_REQUEST_DATE_RUN = 0x00000800
EVERYTHING_REQUEST_DATE_RECENTLY_CHANGED = 0x00001000
EVERYTHING_REQUEST_HIGHLIGHTED_FILE_NAME = 0x00002000
EVERYTHING_REQUEST_HIGHLIGHTED_PATH = 0x00004000
EVERYTHING_REQUEST_HIGHLIGHTED_FULL_PATH_AND_FILE_NAME = 0x00008000
#dll imports
everything_dll = ctypes.WinDLL (r"C:\Users\PythonProjects\Everything-SDK\.venv\Lib\dll\Everything64.dll")
everything_dll.Everything_GetResultDateModified.argtypes = [ctypes.c_int,ctypes.POINTER(ctypes.c_ulonglong)]
everything_dll.Everything_GetResultSize.argtypes = [ctypes.c_int,ctypes.POINTER(ctypes.c_ulonglong)]
everything_dll.Everything_GetResultFileNameW.argtypes = [ctypes.c_int]
everything_dll.Everything_GetResultFileNameW.restype = ctypes.c_wchar_p
#setup search
everything_dll.Everything_SetSearchW("")
# everything_dll.Everything_SetRequestFlags(EVERYTHING_REQUEST_FILE_NAME | EVERYTHING_REQUEST_PATH | EVERYTHING_REQUEST_SIZE | EVERYTHING_REQUEST_DATE_MODIFIED)
everything_dll.Everything_SetRequestFlags(EVERYTHING_REQUEST_HIGHLIGHTED_FULL_PATH_AND_FILE_NAME)
#execute the query
everything_dll.Everything_QueryW(1)
#get the number of results
num_results = everything_dll.Everything_GetNumResults()
#show the number of results
print("Result Count: {}".format(num_results))
print(everything_dll.Everything_GetResultHighlightedFullPathAndFileName(0))
I fixed this error by switching to the "64.dll".
Code: Select all
File "C:\Users\PythonProjects\Everything-SDK\Everything-SDK-example.py", line 25, in <module>
everything_dll = ctypes.WinDLL (r"C:\Users\PythonProjects\Everything-SDK\.venv\Lib\dll\Everything32.dll")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: [WinError 193] %1 is not a valid Win32 application
I keep getting this message whenever I try to get highlighted results.
Code: Select all
File "C:\Users\PythonProjects\Everything-SDK\Everything-SDK-example.py", line 45, in <module>
print(everything_dll.Everything_GetResultHighlightedFullPathAndFileName(0))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: function 'Everything_GetResultHighlightedFullPathAndFileName' not found
Any suggestions for the AttributeError?
void
Developer
Posts: 16748 Joined: Fri Oct 16, 2009 11:31 pm
Post
by void » Fri Dec 08, 2023 12:30 am
Please try the following function name instead:
Everything_GetResultHighlightedFullPathAndFileNameW
A = ANSI, W = Unicode (Wchar)
Tank Ersley
Posts: 11 Joined: Sat Aug 05, 2023 5:48 pm
Post
by Tank Ersley » Fri Dec 08, 2023 4:03 pm
I think I'm headed down the wrong path.
Everything_GetNumResults still indicates that all indexed files are being returned.
Is there a way to get information on the files that are selected in the Everything GUI?
If not, is there a way to display the "visible results" that the SDK keeps referring to so I can get an idea of what's going on?
void
Developer
Posts: 16748 Joined: Fri Oct 16, 2009 11:31 pm
Post
by void » Fri Dec 08, 2023 10:25 pm
Everything_GetNumResults still indicates that all indexed files are being returned.
Please make sure you call
Everything_SetOffset and
Everything_SetMax before
Everything_Query
Everything_GetNumResults should return the count specified in Everything_SetMax() (or less).
Is there a way to get information on the files that are selected in the Everything GUI?
Yes, Everything uses an emulated ListView32 control.
If not, is there a way to display the "visible results" that the SDK keeps referring to so I can get an idea of what's going on?
To check the IPC request in Everything:
Type in the following search and press ENTER:
/debug
---this will show a debug console---
IPC requests are shown in Cyan color.
To hide the Everything debug console:
Type in the following search and press ENTER:
/debug
Tank Ersley
Posts: 11 Joined: Sat Aug 05, 2023 5:48 pm
Post
by Tank Ersley » Sun Dec 10, 2023 3:58 am
I'm such a dummy!
The Everything SDK provides a DLL and Lib interface to Everything over IPC .
The Everything IPC allows applications to query and get search results from the "Everything" database .
It says so right there. So, the SDK interacts with the database, not the interface.
I was hoping that I could select random files in the GUI (that could not be easily filtered with a query) and have the SDK return the filenames.
I understand now that's not how it works.
Sorry for the confusion.
void
Developer
Posts: 16748 Joined: Fri Oct 16, 2009 11:31 pm
Post
by void » Sun Dec 10, 2023 4:11 am
I was hoping that I could select random files in the GUI
You can do this with
FindWindow ,
LVM_SETITEMSTATE and
LVM_GETITEMTEXT
To get the result list window:
GetDlgItem(FindWindow(EVERYTHING_IPC_SEARCH_CLIENT_WNDCLASS,0),EVERYTHING_IPC_ID_RESULT_LIST)
EVERYTHING_IPC_SEARCH_CLIENT_WNDCLASS = "EVERYTHING"
EVERYTHING_IPC_ID_RESULT_LIST = 10020
You may need to marshal LVM_GETITEMTEXT (depending on your programming language)
Everything currently doesn't have a way to get highlighted results from the result list.