├── LICENSE ├── README.md └── everything.py /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Python-EveryThing-SDK 2 | https://www.voidtools.com/support/everything/sdk/ 3 | 4 | ```py 5 | everything = Everything() 6 | # sets the search options 7 | everything.set_search('everything') 8 | everything.set_request_flags(Request.FullPathAndFileName|Request.DateModified|Request.Size) 9 | # starts the search 10 | if not everything.query(): 11 | raise Exception(everything.get_last_error()) 12 | # prints all results 13 | for item in everything: 14 | print( 15 | item.get_filename(), 16 | f'Size: {item.get_size()} Bytes', 17 | f'Modified date: {item.get_date_modified()}', 18 | '', sep='\n' 19 | ) 20 | ``` 21 | -------------------------------------------------------------------------------- /everything.py: -------------------------------------------------------------------------------- 1 | """ 2 | The Everything SDK provides a DLL and Lib interface to Everything over IPC. 3 | Everything is required to run in the background. 4 | 5 | documentation : https://www.voidtools.com/support/everything/sdk/ 6 | dependency (SDK): https://www.voidtools.com/Everything-SDK.zip 7 | """ 8 | import os, ctypes 9 | import datetime as dt 10 | from typing import Final 11 | from enum import Enum, IntEnum 12 | from ctypes.wintypes import * 13 | from struct import calcsize, unpack 14 | 15 | MAX_PATH: Final = 32767 16 | 17 | class Request(IntEnum): 18 | FileName = 0x00000001 19 | Path = 0x00000002 20 | FullPathAndFileName = 0x00000004 21 | Extension = 0x00000008 22 | Size = 0x00000010 23 | DateCreated = 0x00000020 24 | DateModified = 0x00000040 25 | DateAccessed = 0x00000080 26 | Attributes = 0x00000100 27 | FileListFileName = 0x00000200 28 | RunCount = 0x00000400 29 | DateRun = 0x00000800 30 | DateRecentlyChanged = 0x00001000 31 | HighlightedFileName = 0x00002000 32 | HighlightedPath = 0x00004000 33 | HighlightedFullPathAndFileName = 0x00008000 34 | All = 0x0000FFFF 35 | 36 | class Error(Enum): 37 | Ok = 0 # The operation completed successfully. 38 | Memory = 1 # Failed to allocate memory for the search query. 39 | IPC = 2 # IPC is not available. 40 | RegisterClassEx = 3 # Failed to register the search query window class. 41 | CreateWindow = 4 # Failed to create the search query window. 42 | CreateThread = 5 # Failed to create the search query thread. 43 | InvalidIndex = 6 # Invalid index. The index must be greater or equal to 0 and less than the number of visible results. 44 | InvalidCall = 7 # Invalid call. 45 | 46 | class ItemIterator: 47 | def __init__(self, everything, index): 48 | self.everything = everything 49 | self.index = index 50 | 51 | def __next__(self): 52 | self.index += 1 53 | if self.index < len(self.everything): 54 | return self 55 | raise StopIteration 56 | 57 | def __str__(self): 58 | return self.get_filename() 59 | 60 | def get_filename(self): 61 | """ 62 | Gets the full path and file name of a visible result. 63 | :return: Returns a string if successful, otherwise returns None. 64 | """ 65 | filename = ctypes.create_unicode_buffer(MAX_PATH) 66 | if self.everything.GetResultFullPathNameW(self.index, filename, MAX_PATH): 67 | return filename.value 68 | return None 69 | 70 | def get_size(self): 71 | """ 72 | Gets the size of a visible result. 73 | :return: Returns the size if successful, otherwise returns None. 74 | """ 75 | file_size = ULARGE_INTEGER() 76 | if self.everything.GetResultSize(self.index, file_size): 77 | return file_size.value 78 | return None 79 | 80 | def get_date_accessed(self): 81 | """ 82 | Gets the accessed date of the visible result. 83 | """ 84 | return self._get_result_date('Accessed') 85 | 86 | def get_date_created(self): 87 | """ 88 | Gets the created date of the visible result. 89 | """ 90 | return self._get_result_date('Created') 91 | 92 | def get_date_modified(self): 93 | """ 94 | Gets the modified date of the visible result. 95 | """ 96 | return self._get_result_date('Modified') 97 | 98 | def get_date_recently_changed(self): 99 | """ 100 | Gets the recently changed date of the visible result. 101 | """ 102 | return self._get_result_date('RecentlyChanged') 103 | 104 | def get_date_run(self): 105 | """ 106 | Gets the run date of the visible result. 107 | """ 108 | return self._get_result_date('Run') 109 | 110 | def is_file(self): 111 | """ 112 | Determines if the visible result is a file. 113 | """ 114 | return bool(self.everything.IsFileResult(self.index)) 115 | 116 | def is_folder(self): 117 | """ 118 | Determines if the visible result is a folder. 119 | """ 120 | return bool(self.everything.IsFolderResult(self.index)) 121 | 122 | def _get_result_date(self, tdate): 123 | filetime_date = ULARGE_INTEGER() 124 | if self.everything(f'GetResultDate{tdate}', self.index, filetime_date): 125 | winticks = int(unpack('