### UpdateChecker Usage Example Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/api-reference/UpdateChecker.md Demonstrates how to use the UpdateChecker.Async method to check for and potentially install updates. Ensure necessary settings and update settings are configured. ```csharp var currentVersion = Assembly.GetExecutingAssembly().GetName().Version; var checker = new UpdateChecker(); var settings = new Settings { Updates = true }; var updateSettings = new UpdateSettings(); await checker.Async(currentVersion, settings, updateSettings, isArm: false); // If newer version available and user clicks Yes, update installer downloads and launches ``` -------------------------------- ### Install EverythingPowerToys using WinGet Source: https://github.com/lin-ycv/everythingpowertoys/wiki/Home Use this command to install EverythingPowerToys via WinGet. WinGet is preinstalled on modern Windows versions. Everything needs to be installed separately. ```bash winget install lin-ycv.EverythingPowerToys ``` -------------------------------- ### Install Everything using WinGet Source: https://github.com/lin-ycv/everythingpowertoys/wiki/Home Command to install Everything as a dependency using WinGet. Choose between the standard or alpha version. ```bash winget install voidtools.everything OR winget install voidtools.everything.alpha ``` -------------------------------- ### Install EverythingPowerToys using Scoop Source: https://github.com/lin-ycv/everythingpowertoys/wiki/Home Use this command to install EverythingPowerToys via Scoop. Ensure Scoop is installed and dependencies are handled separately. ```bash scoop bucket add extras | scoop install extras/everything-powertoys ``` -------------------------------- ### Install Everything using Scoop Source: https://github.com/lin-ycv/everythingpowertoys/wiki/Home Command to install Everything as a dependency using Scoop. Choose between the standard or alpha version. ```bash scoop bucket add extras | scoop install extras/everything OR scoop bucket add versions | scoop install versions/everything-alpha ``` -------------------------------- ### Custom Program Action Setup Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/configuration.md Configures a custom program and arguments for launching files via the context menu. The `$P` placeholder is replaced with the file path. ```text CustomProgram: `code` (Visual Studio Code) CustomArg: `$P` (or `--add $P` to add folder) Action: Right-click a file → "Open in Custom Program" → Launches VS Code with file ``` -------------------------------- ### Install EverythingPowerToys using Chocolatey Source: https://github.com/lin-ycv/everythingpowertoys/wiki/Home Use this command to install EverythingPowerToys via Chocolatey. Ensure Chocolatey is installed and dependencies are handled separately. ```bash choco install everythingpowertoys ``` -------------------------------- ### Example: Creating and Using SearchResult Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/api-reference/SearchResult.md Provides a consolidated example of creating a SearchResult instance and then using its properties to perform file or folder-specific operations like deletion. ```csharp // Creation (in Everything.cs) var result = new SearchResult { Path = @"C:\\Users\\Documents\\report.pdf", Title = "report.pdf", File = true }; // Usage (in ContextMenuLoader.cs) if (result.File) { // Handle file-specific operations File.Delete(result.Path); } else { // Handle folder-specific operations Directory.Delete(result.Path, recursive: true); } ``` -------------------------------- ### Install PowerToys using Scoop Source: https://github.com/lin-ycv/everythingpowertoys/wiki/Home Command to install PowerToys as a dependency using Scoop. ```bash scoop bucket add extras | scoop install extras/powertoys ``` -------------------------------- ### MatchPath Search Example Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/configuration.md Illustrates matching search queries against the full file path. When enabled, the query is checked against the entire path; otherwise, it only matches against the filename. ```text Query: `Documents` with MatchPath off matches filenames containing "Documents" With MatchPath on: Matches files in paths like "C:\Users\Documents\" or "C:\Documents and Settings\" ``` -------------------------------- ### EnvVar Expansion Example Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/configuration.md Shows how Windows environment variables in queries are expanded. For example, `%TEMP%` is replaced with the actual temporary directory path. ```text Query: `%TEMP%\*` expands to actual temp directory path (e.g., "C:\Users\Alice\AppData\Local\Temp\*") Replace semicolon separators with pipes for multiple paths ``` -------------------------------- ### Example Usage of LoadContextMenus Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/api-reference/ContextMenuLoader.md Demonstrates how to use the LoadContextMenus method to get context menu items for a given search result and iterate through them. ```csharp var result = new Result { ContextData = new SearchResult { Path = "C:\\file.txt", File = true } }; var contextMenus = loader.LoadContextMenus(result); // contextMenus contains up to 9 items depending on Context setting foreach (var item in contextMenus) { // Render menu item to user } ``` -------------------------------- ### Prefix Query Example Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/configuration.md Demonstrates prepending a string to all search queries. This is useful for applying a consistent filter, such as a file size constraint. ```text Prefix: `size:>10MB ` prepends to all queries Query: `*.log` becomes `size:>10MB *.log` (returns files > 10 MB) ``` -------------------------------- ### Install Everything using Chocolatey Source: https://github.com/lin-ycv/everythingpowertoys/wiki/Home Command to install Everything as a dependency using Chocolatey. Choose between the standard or development version. ```bash choco install everything OR choco install everything-development ``` -------------------------------- ### Install PowerToys using Chocolatey Source: https://github.com/lin-ycv/everythingpowertoys/wiki/Home Command to install PowerToys as a dependency using Chocolatey. ```bash choco install powertoys ``` -------------------------------- ### Programmatic Filter Loading Example Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/api-reference/Settings.md Demonstrates how to instantiate the Settings class and call the Getfilters() method programmatically to load filters. The Filters dictionary is then populated. ```csharp var settings = new Settings(); settings.Getfilters(); // Now settings.Filters contains: // { "audio:" -> "ext:aac;ac3;...", "zip:" -> "ext:7z;...", ... } ``` -------------------------------- ### RegEx Search Example Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/configuration.md Demonstrates how to use regular expressions for filename matching. When enabled, the query is interpreted as a pattern; otherwise, it's treated as a literal wildcard search. ```text Query: `test.*\.txt` with RegEx enabled matches "test123.txt", "test_report.txt", etc. Without RegEx: Searches for literal filename containing "test.*\.txt" ``` -------------------------------- ### UpdateSettings Persistence Example Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/api-reference/UpdateChecker.md Illustrates how UpdateSettings are loaded and saved using PluginJsonStorage. This is crucial for maintaining the user's 'skip' version preference across sessions. ```csharp // Main.cs private readonly PluginJsonStorage _storage = new(); // In Init() Update.UpdateSettings upSettings = _storage.Load(); // ... pass to UpdateChecker.Async() // In Save() _storage.Save(); ``` -------------------------------- ### Everything 1.4 with Custom Filters Configuration Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/configuration.md Configure Everything 1.4 with custom file type filters for specific searches. This example shows how to set up filters for audio, zip, documents, executables, pictures, and videos. ```plaintext Max: 15 Sort: NAME_ASCENDING Prefix: (empty) Updates: Off LoggingLevel: Error # settings.toml loaded with Audio:, Zip:, Doc:, Exe:, Pic:, Video: filters ``` -------------------------------- ### NSIS Build and Checksum Commands Source: https://github.com/lin-ycv/everythingpowertoys/wiki/Developer These commands are part of the Post Build event for creating an installer and checksums. They require NSIS to be installed. ```shell C:\Program Files (x86)\NSIS\makensis" /Dver=$(Version) /Ddirect=$(TargetDir) /Dplatform=$(Platform) .\NSIS\exeCreator.nsi certUtil -hashfile .\bin\EverythingPT-$(Version)-$(Platform).zip SHA256 >> .\bin\$(Platform)_CHECKSUM.txt certUtil -hashfile .\bin\EverythingPT-$(Version)-$(Platform).exe SHA256 >> .\bin\$(Platform)_CHECKSUM.txt ``` -------------------------------- ### Build Everything PowerToys Plugin Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/README.md Builds the plugin project in Release configuration for the x64 platform. Ensure you have Visual Studio 2022+ and the .NET 8.0 SDK installed. ```bash dotnet build Community.PowerToys.Run.Plugin.Everything.csproj -c Release -p:Platform=x64 ``` -------------------------------- ### QueryText Display Example Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/configuration.md Explains how the original user query is displayed in the result subtitle. When enabled, the subtitle shows the query; otherwise, it shows the result's filename. ```text User searches "report" With QueryText off: Result subtitle shows "report.pdf" (the filename) With QueryText on: Result subtitle shows "report" (the original query) ``` -------------------------------- ### Usage Example in Query Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/api-reference/Settings.md Illustrates how a user search query containing a filter keyword (e.g., 'audio:') is processed. The keyword is removed, and the corresponding Everything search syntax is appended. ```text If user searches `audio: music`, the Everything wrapper checks if query contains `audio:` (case-insensitive), removes the keyword, and appends ` ext:aac;ac3;...` to transform into Everything syntax. ``` -------------------------------- ### UpdateChecker.Async Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/api-reference/UpdateChecker.md Checks for new plugin releases on GitHub and optionally downloads and installs them. This method runs asynchronously and prompts the user if a newer version is available. ```APIDOC ## Async(Version v, Settings s, UpdateSettings us, bool isArm) ### Description Checks for plugin updates and optionally downloads and installs if a newer version is available. This method performs asynchronous operations. ### Method `async Task` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters Table | Parameter | Type | Required | Default | Description | |-----------|------|----------|---------|-------------| | v | Version | Yes | — | Current plugin version (from assembly metadata) | | s | Settings | Yes | — | Plugin settings (for logging and UI preferences) | | us | UpdateSettings | Yes | — | Persistent update state (stores user's "skip" version) | | isArm | bool | Yes | — | True if running on ARM64 architecture, false for x64 | ### Response #### Success Response `Task` — Async task that completes after update check. ### Behavior Details 1. **GitHub API Request:** Makes a GET request to `https://api.github.com/repos/lin-ycv/EverythingPowerToys/releases/latest`. 2. **Version Comparison:** Compares the latest release tag with the current version and the skipped version. 3. **User Prompt:** If a newer version is found and not skipped, a MessageBox prompts the user to update. 4. **Update Installation:** If the user agrees, the appropriate installer (x64 or ARM64) is downloaded and executed. 5. **Error Handling:** Catches all exceptions internally and logs them, ensuring graceful continuation. ### Example ```csharp var currentVersion = Assembly.GetExecutingAssembly().GetName().Version; var checker = new UpdateChecker(); var settings = new Settings { Updates = true }; var updateSettings = new UpdateSettings(); await checker.Async(currentVersion, settings, updateSettings, isArm: false); ``` ``` -------------------------------- ### Conditional Logging Based on Level Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/errors.md This example shows how to implement conditional logging based on a configured logging level. Messages are only logged if the current logging level is less than or equal to the specified level (e.g., Debug or Error). ```csharp // Only logged if LoggingLevel <= LogLevel.Debug if (setting.LoggingLevel <= LogLevel.Debug) Log.Info("EPT: Init", GetType()); // Only logged if LoggingLevel < LogLevel.Error (Trace, Debug, Info, Warn) if (setting.LoggingLevel < LogLevel.Error) Log.Warn($"EPT: Unable to Query ({code})", GetType()); ``` -------------------------------- ### Main Plugin Initialization Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/api-reference/Main.md Initializes the Everything PowerToys Run plugin, preparing it for operation by loading settings, setting up the Everything search wrapper, and configuring context menu operations. ```APIDOC ## Init(PluginInitContext context) ### Description Initializes the plugin and prepares it for operation. ### Method Init ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - None ### Request Example ```csharp var plugin = new Main(); plugin.Init(pluginContext); ``` ### Response #### Success Response - None (void method) #### Response Example - None ``` -------------------------------- ### Initialize Everything Search Wrapper Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/api-reference/Everything.md Initializes the Everything search wrapper with specified settings. This constructor configures the SDK for retrieving file names and paths and applies initial user preferences. ```csharp internal sealed class Everything { // ... constructor and other members ... } ``` ```csharp internal Everything(Settings setting) ``` ```csharp var settings = new Settings(); var everything = new Everything(settings); ``` -------------------------------- ### UpdateChecker Class Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/README.md The UpdateChecker class manages the plugin's update process, including checking for new versions and installing them from GitHub releases. ```APIDOC ## UpdateChecker Class ### Description This class is responsible for checking if a newer version of the Everything PowerToys plugin is available on GitHub and for handling the update installation process. ### Methods - **Async(Version, Settings, UpdateSettings, bool)**: Asynchronously checks for updates, potentially downloading and installing a new version based on the provided current version, settings, and update configuration. ``` -------------------------------- ### Everything Plugin Type Usage Flow Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/types.md Illustrates the sequence of operations and data flow within the Everything plugin, from initial query to result selection and context menu loading. Settings updates are also shown to propagate through the system. ```text Query (PowerToys Run) ↓ Main.Query(Query) ↓ Everything.Query(string) uses Sort, Request ↓ Result[] (with ContextData: SearchResult) ↓ User selects result ↓ ContextMenuLoader.LoadContextMenus(Result) ↓ ContextMenuResult[] (using SearchResult from ContextData) ``` -------------------------------- ### Initialize Plugin Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/api-reference/Main.md Initializes the plugin with the provided PowerToys Run context. This method handles loading settings, setting up the Everything search wrapper, and preparing context menu operations. ```csharp public void Init(PluginInitContext context) ``` ```csharp var plugin = new Main(); plugin.Init(pluginContext); ``` -------------------------------- ### Define ShellContextMenuException Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/errors.md Custom exception for Windows shell context menu operation failures. Used when operations like getting the desktop shell folder fail. ```csharp public class ShellContextMenuException : Exception ``` -------------------------------- ### Creating a SearchResult in Everything.cs Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/api-reference/SearchResult.md Demonstrates how to create a SearchResult instance within the Everything.cs Query() method, populating its Path, Title, and File properties. ```csharp // From Everything.cs Query() method (line 241-246) var r = new Result() { // ... other Result properties ContextData = new SearchResult() { Path = fullPath, // e.g., "C:\\Users\\Alice\\document.txt" Title = name, // e.g., "document.txt" File = !isFolder, // true for files, false for folders }, // ... }; ``` -------------------------------- ### PowerToys Run Query Transformation Pipeline Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/README.md Shows how user queries are transformed before being passed to the Everything SDK. This pipeline includes prefixing, environment variable expansion, and filter keyword transformation for Everything 1.4. ```mermaid graph TD User Query: "*.txt" ↓ (if Prefix set) → "MyPrefix *.txt" ↓ (if EnvVar) → Expand %VARIABLE% and replace ; with | ↓ (if Everything 1.4 and Contains ':') → Check Filters dict, transform keywords ↓ Everything_SetSearchW(transformed_query) ↓ Everything_QueryW(true) ↓ Result enumeration ``` -------------------------------- ### Handle Generic Exception for Process Execution Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/errors.md Catches exceptions during process execution, such as when starting a program or killing a process fails. This handler is used for TaskSchedulerException and other execution-related errors, marking the action as failed. ```csharp try { process.Start(); return true; } catch (Exception e) { Log.Exception($"EPT: Failed to execute {_customProgram}", e, GetType()); return false; } ``` -------------------------------- ### Handle Win32Exception for File Open Failure Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/errors.md Catches Win32Exception when attempting to open a file or folder fails, for example, if no program is associated with the file type or due to permission issues. The action is silently marked as failed. ```csharp catch (Win32Exception) { return false; // Context menu action returns false } ``` -------------------------------- ### Clone EverythingPowerToys Repository Source: https://github.com/lin-ycv/everythingpowertoys/wiki/Developer Clone the main PowerToys repository and then clone the EverythingPowerToys fork into the appropriate plugins directory. ```shell git clone https://github.com/microsoft/PowerToys.git cd .\PowerToys git submodule update --init --recursive cd .\src\modules\launcher\Plugins git clone https://github.com/lin-ycv/EverythingPowerToys.git --depth 1 cd ../../../../ ``` -------------------------------- ### Load Context Menus Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/api-reference/Main.md Generates context menu options for a given search result. The available actions, such as opening a folder or copying a file path, are determined by user configurations. ```csharp public List LoadContextMenus(Result selectedResult) ``` ```csharp var result = new Result { /* ... */ }; var contextMenus = plugin.LoadContextMenus(result); // Present menu items to user ``` -------------------------------- ### PowerToys Run Search Query Flow Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/README.md Illustrates the sequence of calls from user input to displaying search results using the Everything SDK. This flow involves PowerToys Run, the Main query function, and the Everything SDK functions for setting search parameters and retrieving results. ```mermaid graph TD PowerToys Run User Input (backtick + query) ↓ Main.Query(Query) ↓ Everything.Query(string) ├─ Everything_SetSearchW(query) ├─ Everything_QueryW(true) └─ Everything_GetResultFileNameW(), Everything_GetResultPathW() (per result) ↓ Result[] (with SearchResult ContextData) ↓ PowerToys Run UI Display ``` -------------------------------- ### Handle Missing Settings File Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/errors.md Catches FileNotFoundException when the settings.toml file is missing. Logs the error and returns early, preventing filter transformations. ```csharp catch (FileNotFoundException ex) { Log.Error("Settings file not found: {0}", ex.Message); return; } ``` -------------------------------- ### Load Context Menus Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/api-reference/Main.md Generates context menu options for a selected search result, providing actions like opening the item, running as administrator, or copying paths. ```APIDOC ## LoadContextMenus(Result selectedResult) ### Description Generate context menu options for a selected search result. ### Method LoadContextMenus ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - **selectedResult** (Result) - Required - The search result item selected by user ### Request Example ```csharp var result = new Result { /* ... */ }; var contextMenus = plugin.LoadContextMenus(result); // Present menu items to user ``` ### Response #### Success Response (200) - **List** - List of context menu actions (0–9 items) #### Response Example ```json [ { "Text": "Open file location", "PluginName": "Everything", "ActionKeyword": "Everything", "ExtraData": "C:\\Users\\User\\Documents\\Example.txt", "JsonRPCAction": null } ] ``` ``` -------------------------------- ### CreateSettingPanel() Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/api-reference/Main.md Reserved for future UI integration. This method is not currently implemented. ```APIDOC ## CreateSettingPanel() ### Description Reserved for future UI integration (not implemented). ### Method Signature ```csharp public Control CreateSettingPanel() ``` ### Throws NotImplementedException ``` -------------------------------- ### Execute a Search Query Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/api-reference/Everything.md This snippet demonstrates how to execute a search query using the Everything API and iterate through the results. It includes basic error handling for query cancellation and service errors. ```csharp internal IEnumerable Query(string query, Settings setting, CancellationToken token) ``` ```csharp var cts = new CancellationTokenSource(); try { var results = everything.Query("*.txt", settings, cts.Token); foreach (var result in results) { // Process each result } } catch (OperationCanceledException) { // Query was cancelled } catch (Win32Exception) { // Everything service error } ``` -------------------------------- ### Everything Search Wrapper Class Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/README.md The Everything class acts as a wrapper for the Everything search engine SDK, handling search execution and configuration. ```APIDOC ## Everything Class ### Description This class provides a C# interface to the Everything search engine's native SDK. It is responsible for executing search queries and managing the configuration of the SDK, including discovering the `Everything.exe` location. ### Methods - **Query(string, Settings, CancellationToken)**: Executes a search using the Everything SDK with the specified query string, settings, and cancellation token. - **UpdateSettings(Settings)**: Updates the internal settings of the Everything SDK wrapper and attempts to discover the `Everything.exe` executable. ``` -------------------------------- ### Main Plugin Class Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/README.md The Main class serves as the plugin's entry point, coordinating its lifecycle, search queries, and settings management within the PowerToys Run framework. ```APIDOC ## Main Class ### Description This class is the primary entry point for the Everything PowerToys plugin. It implements key interfaces for the PowerToys Run framework, including lifecycle management, search execution, settings updates, and context menu generation. ### Methods - **Init(PluginInitContext)**: Initializes the plugin with the provided context. - **Query(Query, bool)**: Executes a search query based on the provided query object and a boolean flag. - **UpdateSettings(PowerLauncherPluginSettings)**: Applies updated user settings to the plugin. - **LoadContextMenus(Result)**: Generates and loads context menu items for a given search result. - **Dispose()**: Cleans up any resources used by the plugin. ``` -------------------------------- ### Context Menu Actions Configuration Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/configuration.md Defines which context menu actions are enabled for files. A string of digits (0-8) specifies the desired actions, where each digit corresponds to a specific action. ```text 0 = Open Containing Folder 1 = Run as Administrator 2 = Run as Different User 3 = Copy File 4 = Copy Path 5 = Open in Console 6 = Open in Custom Program 7 = Delete 8 = Shell Context Menu Example: `Context = "0345"` enables only options 0, 3, 4, 5; hides options 1, 2, 6, 7, 8. ``` -------------------------------- ### Basic Everything Search Configuration Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/configuration.md Configure basic search parameters like maximum results, sorting, and preview options. This is useful for general file searching. ```plaintext Max: 20 Sort: NAME_ASCENDING RegEx: Off MatchPath: Off Prefix: (empty) QueryText: Off Preview: On ShowMore: On Updates: On LoggingLevel: Error ``` -------------------------------- ### Component Diagram Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/README.md Illustrates the architectural components and their relationships within the Everything PowerToys plugin. ```text PowerToys Run Framework │ └── Main.cs (IPlugin, IDelayedExecutionPlugin, IContextMenu, ISettingProvider) │ ├── Everything.cs (Search Wrapper) │ └── Everything2_x64.dll / Everything2_ARM64.dll (Native SDK) │ ├── Settings.cs (Configuration) │ └── settings.toml (Filter Definitions) │ ├── ContextMenuLoader.cs (File Operations) │ └── ShellContextMenu.cs (Windows Shell Integration) │ └── UpdateChecker.cs (GitHub Integration) └── GitHub API (https://api.github.com) ``` -------------------------------- ### Configuration Options Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/api-reference/Main.md Defines user-configurable settings exposed in the PowerToys Run UI. ```APIDOC ## Configuration Options ### Description The `AdditionalOptions` property defines all user-configurable settings exposed in PowerToys Run UI: | Key | Type | Label | Description | |-----|------|-------|-------------| | Context | Textbox | "Context" | Custom context menu options (digits 0–8 enable/disable specific actions) | | Sort | Combobox | "Sort" | Result sort order (1–28 corresponding to Sort enum values) | | Max | Numberbox | "Max" | Maximum number of results to return | | Prefix | Textbox | "Prefix" | String to prepend to all search queries | | EverythingPath | Textbox | "Everything Path" | Manual path to Everything.exe if auto-detection fails | | CustomProgram | Textbox | "Custom Program" | Program to open files with (context menu option 6) | | CustomArg | Textbox | "Custom Argument" | Argument template for custom program (use $P for file path) | | Copy | Toggle | "Swap Copy" | Whether Ctrl+C copies file vs. path (false = path, true = file) | | EnvVar | Toggle | "Environment Variables" | Enable environment variable expansion in search queries | | MatchPath | Toggle | "Match Path" | Match query against full path in addition to filename | | Preview | Toggle | "Preview" | Show file icon preview instead of generic file icon | | QueryText | Toggle | "Query Text" | Display original query or result name in result subtitle | | RegEx | Toggle | "Regular Expressions" | Interpret search query as regular expression | | ShowMore | Toggle | "Show More" | Show "More Results" button to open Everything GUI when at result limit | | Updates | Toggle | "Updates" | Check GitHub for plugin updates on startup | | LoggingLevel | Combobox | "Log Level" | NLog logging level for diagnostics | ``` -------------------------------- ### Getfilters() Method Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/api-reference/Settings.md Loads search filters from settings.toml for Everything 1.4 compatibility. This method populates the Filters dictionary and logs diagnostic information. ```csharp internal void Getfilters() ``` -------------------------------- ### Query(string query, Settings setting, CancellationToken token) Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/api-reference/Everything.md Executes a search query against the Everything application and enumerates the results. This method handles query preparation, execution, and result retrieval, with support for cancellation and special 'Show More Results' behavior. ```APIDOC ## Query(string query, Settings setting, CancellationToken token) ### Description Executes a search query and enumerates results. This method prepares the query based on settings, executes it using the Everything SDK, and yields results one by one. It also supports cancellation and a special 'Show More Results' button. ### Method Internal method (not directly callable by external users, but represents a core API function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```csharp var cts = new CancellationTokenSource(); try { var results = everything.Query("*.txt", settings, cts.Token); foreach (var result in results) { // Process each result } } catch (OperationCanceledException) { // Query was cancelled } catch (Win32Exception) { // Everything service error } ``` ### Response #### Success Response (IEnumerable) - **Result** (Type: `Result`) - Represents a single search result, including title, subtitle, icon, and action. #### Response Example (Lazy enumeration, no direct response body example) ### Throws - `OperationCanceledException`: If the cancellation token is signalled during query execution or result enumeration. - `Win32Exception`: If the Everything query fails due to service errors or formatting issues. ``` -------------------------------- ### CreateSettingPanel Method Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/api-reference/Main.md Reserved for future UI integration. This method is not currently implemented and will throw a NotImplementedException. ```csharp public Control CreateSettingPanel() ``` -------------------------------- ### GetTranslatedPluginDescription Method Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/api-reference/Main.md Retrieves the localized plugin description from resources. Returns a string representing the plugin's description. ```csharp public string GetTranslatedPluginDescription() ``` -------------------------------- ### Update Everything Search Settings Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/api-reference/Everything.md Applies or refreshes the Everything search configuration using a Settings object. This method handles various SDK configurations like sort order, result limits, path matching, and regex mode. It also includes logic for discovering the Everything.exe path on the first call. ```csharp internal void UpdateSettings(Settings setting) ``` ```csharp var newSettings = new Settings { Max = 20, RegEx = true }; everything.UpdateSettings(newSettings); ``` -------------------------------- ### Create New Translation Resource File Source: https://github.com/lin-ycv/everythingpowertoys/wiki/Developer Duplicate the default Resources.resx file and rename it to include the locale code for a new translation. ```xml Resources.zh-tw.resx ``` -------------------------------- ### Execute Search Query Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/api-reference/Main.md Executes a search query against the Everything search engine, returning a list of results formatted for the PowerToys Run interface. ```APIDOC ## Query(Query query, bool delayedExecution) ### Description Execute a search query against Everything. ### Method Query ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - **query** (Query) - Required - Query object containing the search string from user input - **delayedExecution** (bool) - Required - Whether to use delayed execution (typically true for this plugin) ### Request Example ```csharp var queryObj = new Query { Search = "*.txt" }; var results = plugin.Query(queryObj, delayedExecution: true); // results contains Result objects ready for UI display ``` ### Response #### Success Response (200) - **List** - List of search results formatted for PowerToys Run display #### Response Example ```json [ { "Title": "Example.txt", "SubTitle": "C:\\Users\\User\\Documents", "IcoPath": "Everything", "Path": "C:\\Users\\User\\Documents\\Example.txt", "Score": 100, "ActionKeyword": "Everything", "ExtraData": null, "JsonRPCAction": null } ] ``` ``` -------------------------------- ### Handle Custom Program Launch Failure Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/errors.md Catches Win32Exception when a custom program executable is not found. Logs the error and returns false, allowing the plugin to continue operating. ```csharp catch (Win32Exception ex) { Log.Error("Failed to start custom program: {0}", ex.Message); return false; } ``` -------------------------------- ### Initialize ContextMenuLoader Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/api-reference/ContextMenuLoader.md Initializes the context menu handler with plugin context and initial settings. The options string determines which context menu items are enabled. ```csharp internal sealed class ContextMenuLoader ``` ```csharp internal ContextMenuLoader(PluginInitContext context, string options) ``` ```csharp var loader = new ContextMenuLoader(pluginContext, "01234568"); ``` -------------------------------- ### Handle Win32Exception for Query Failure Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/errors.md Catches Win32Exception that occurs when the Everything SDK fails to execute a query. Displays a user-friendly message indicating the Everything service might not be running. ```csharp catch (System.ComponentModel.Win32Exception) { results.Add(new Result() { Title = Resources.Everything_not_running, SubTitle = Resources.Everything_ini, IcoPath = "Images/warning.png", Score = int.MaxValue, }); } ``` -------------------------------- ### PowerToys Run Context Menu Action Flow Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/README.md Details the process for handling context menu actions on search results within PowerToys Run. This includes loading menus, executing actions, and updating Everything statistics. ```mermaid graph TD User selects search result ↓ ContextMenuLoader.LoadContextMenus(Result) ├─ Extracts SearchResult from ContextData ├─ Determines file vs. folder ├─ Generates 0–9 ContextMenuResult items └─ Each item contains Title, Glyph, Accelerator, Action Func ↓ User clicks context menu item ↓ Action Func executes (File.Delete, Process.Start, Clipboard.SetData, etc.) ↓ Everything_IncRunCountFromFileNameW() (update statistics) ↓ PowerToys UI updates to show action result ``` -------------------------------- ### Plugin.json Static Metadata Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/configuration.md Static configuration for the plugin, including its ID, name, and execution details. This file is not user-configurable. ```json { "ID": "A86867E2D932459CBD77D176373DD657", "ActionKeyword": "`", "IsGlobal": true, "Name": "Everything", "Author": "Yu Chieh (Victor) Lin", "Version": "0.91.1", "Language": "csharp", "Website": "https://github.com/Lin-ycv/EverythingPowerToys", "ExecuteFileName": "Community.PowerToys.Run.Plugin.Everything.dll", "IcoPathDark": "Images\Everything.dark.png", "IcoPathLight": "Images\Everything.light.png" } ``` -------------------------------- ### Developer Workflow: Search Code Files Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/configuration.md Configure search for developer workflows, enabling regex, path matching, and opening files in a custom program like VS Code. Useful for quickly finding and editing code. ```plaintext Max: 30 Sort: NAME_ASCENDING Prefix: (empty) RegEx: On MatchPath: On Context: "01345" CustomProgram: code CustomArg: $P Preview: On QueryText: Off Updates: On LoggingLevel: Info ``` -------------------------------- ### Module Descriptions Table Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/README.md Provides a summary of each module's responsibility and its corresponding source file. ```text | Module | Responsibility | Source File | |--------|-----------------|-------------| | **Main** | Plugin lifecycle, query coordination, settings management | Main.cs | | **Everything** | Search execution, result retrieval, Everything.exe discovery | Everything.cs | | **Settings** | Configuration state, filter loading for Everything 1.4 | Settings.cs | | **SearchResult** | Data model for search results | SearchHelper/SearchResult.cs | | **ContextMenuLoader** | Context menu generation, file operation actions | ContextMenu/ContextMenuLoader.cs | | **ShellContextMenu** | Windows shell context menu integration | ContextMenu/ShellContextMenu.cs | | **UpdateChecker** | Version checking, GitHub release fetching | Update/UpdateChecker.cs | | **NativeMethods** | P/Invoke bindings to Everything SDK | Interop/NativeMethods.cs | ``` -------------------------------- ### Handle Generic Exception for Context Menu Actions Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/errors.md A general exception handler for various context menu actions. This catches broad exceptions like ArgumentException that might occur due to invalid paths, regex, or file system issues, marking the action as failed. ```csharp catch (Exception e) { Log.Exception($"EPT: Failed to ...", e, GetType()); return false; } ``` -------------------------------- ### settings.toml Filter Definitions Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/configuration.md Define custom file filters using Everything's filter syntax. These are loaded when Everything 1.4 is detected. ```toml # Comments start with # # Syntax: keyword = Everything filter syntax Audio: = ext:aac;ac3;aif;aifc;aiff;amr;ape;au;cda; Zip: = ext:7z;ace;arj;bz2;cab;gz; Doc: = ext:doc;docx;pdf;txt; Exe: = ext:bat;cmd;exe;msi; Pic: = ext:bmp;gif;jpg;png; Video: = ext:3g2;3gp;avi;flv;mkv; ``` -------------------------------- ### Initiating Async Update Check Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/api-reference/UpdateChecker.md This snippet shows how the UpdateChecker is asynchronously invoked during the Main.Init() method. It ensures that update checks do not block the plugin's initialization process by running on a background thread. ```csharp // From Main.cs Init() method (line 189) if (_setting.Updates) Task.Run(() => new Update.UpdateChecker().Async( Assembly.GetExecutingAssembly().GetName().Version, _setting, upSettings, _isArm )); ``` -------------------------------- ### Settings Persistence Location Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/configuration.md Shows the default JSON file location for persisting PowerToys Run Everything plugin settings. This file is loaded on startup and updated when settings are saved. ```json { "Max": 10, "Sort": "NAME_ASCENDING", "RegEx": false, "MatchPath": false, "Prefix": "", "QueryText": false, "Preview": false, "ShowMore": false, "Updates": true, "LoggingLevel": "Info", "Context": "0-8", "CustomProgram": "", "CustomArg": "" } ``` -------------------------------- ### Save() Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/api-reference/Main.md Persists the plugin state to storage. This method is part of the ISavable interface. ```APIDOC ## Save() ### Description Persist plugin state to storage. This method is part of the ISavable interface. ### Behavior - Persists UpdateSettings (e.g., skipped version) to PluginJsonStorage ### Method Signature ```csharp public void Save() ``` ``` -------------------------------- ### Settings.toml File Format Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/api-reference/Settings.md Specifies the format for the settings.toml file, used to define custom filter keywords and their corresponding Everything search syntax. Comments are supported. ```toml # Comment lines start with # # Format: filter:keyword = Everything search syntax Audio: = ext:aac;ac3;aif;... Zip: = ext:7z;ace;arj;... Doc: = ext:doc;docx;pdf;... ``` -------------------------------- ### Verify Plugin DLL Loading Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/errors.md Attempts to load a specified plugin DLL file into the current PowerShell session. Used to check if the DLL is accessible and valid. ```powershell # Verify plugin DLL loads [System.Reflection.Assembly]::LoadFile("C:\path\to\plugin.dll") ``` -------------------------------- ### Main Plugin Class Definition Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/api-reference/Main.md Defines the Main class, which implements various PowerToys Run plugin interfaces. ```csharp public class Main : IPlugin, IDisposable, IDelayedExecutionPlugin, IContextMenu, ISettingProvider, IPluginI18n, ISavable ``` -------------------------------- ### Handle ShellContextMenuException Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/errors.md Demonstrates how to catch and log ShellContextMenuException during context menu operations. This pattern is used when showing a context menu fails. ```csharp try { ShellContextMenu scm = new(); scm.ShowContextMenu(new FileInfo(path), cursorPosition); // Success } catch (ShellContextMenuException e) { Log.Exception("EPT: Failed to show shell context menu", e, GetType()); return false; } ``` -------------------------------- ### LoadContextMenus Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/api-reference/ContextMenuLoader.md Generates context menu actions for a selected search result. It determines available actions based on the item type (file/folder), executability, and user settings. ```APIDOC ## LoadContextMenus(Result selectedResult) ### Description Generate context menu actions for a selected search result. This method analyzes the selected result to determine which context menu options are applicable and returns a list of these actions. ### Method C# Method Signature ### Endpoint N/A (This is an SDK method, not an HTTP endpoint) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example ```csharp var result = new Result { ContextData = new SearchResult { Path = "C:\\file.txt", File = true } }; var contextMenus = loader.LoadContextMenus(result); // contextMenus contains up to 9 items depending on Context setting foreach (var item in contextMenus) { // Render menu item to user } ``` ### Response #### Success Response `List` - A list containing 0–9 context menu items, depending on user settings and file type. #### Response Example ```json [ { "Title": "Open Containing Folder", "Glyph": "🗁 (E838)", "Accelerator": "Ctrl+Shift+E", "Action": "Launch explorer.exe /select,\"path\"" }, { "Title": "Run as Administrator", "Glyph": "🔒 (E7EF)", "Accelerator": "Ctrl+Shift+Enter", "Action": "Elevates .exe/.bat/.appref-ms/.lnk via Helper.RunAsAdmin()" } // ... other context menu items ] ``` ### Behavior Details 1. Extracts `SearchResult` from `selectedResult.ContextData`. 2. Determines if the item is a file or folder via `record.File` property. 3. Checks if the item can be run as administrator (checks for .exe, .bat, .appref-ms, .lnk extensions). 4. Iterates through each character in `_options` (Context setting). 5. For each enabled digit, adds a corresponding `ContextMenuResult`: - **Option 0 (Open Folder):** Only for files. Calls `Helper.OpenInShell`. - **Options 1, 2 (Run as Admin/User):** Only for executables. Calls `Helper.RunAsAdmin` or `Helper.RunAsUser` asynchronously. - **Options 3, 4 (Copy File/Path):** For all items. Sets clipboard content. - **Option 5 (Open in Console):** For all items. Calls `Helper.OpenInConsole`. - **Option 6 (Custom Program):** For all items. Spawns a new process. - **Option 7 (Delete):** For all items. Uses `File.Delete` or `Directory.Delete`. - **Option 8 (Shell Context Menu):** For all items. Shows native Windows context menu. **All actions:** - Call `Everything_IncRunCountFromFileNameW(path)` on success. - Catch and log exceptions internally. - Return `true` on success, `false` on failure. - Show user-friendly error messages via `_context.API.ShowMsg`. ``` -------------------------------- ### Update Plugin Settings Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/api-reference/Main.md Applies new settings to the plugin, which are typically updated from the PowerToys Run UI. This method ensures that the Everything search wrapper and context menu loader reflect the latest configurations. ```csharp public void UpdateSettings(PowerLauncherPluginSettings settings) ``` ```csharp var newSettings = new PowerLauncherPluginSettings(); // ... populate newSettings plugin.UpdateSettings(newSettings); ``` -------------------------------- ### Settings Class Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/types.md Plugin configuration holder. This class contains various boolean and string properties to customize plugin behavior, such as search options, logging level, and custom program paths. ```csharp public class Settings { internal bool Is1_4 { get; set; } internal Sort Sort { get; set; } = Sort.NAME_ASCENDING; internal uint Max { get; set; } = 10; internal string Context { get; set; } = "01234568"; internal bool Copy { get; set; } internal bool MatchPath { get; set; } internal bool Preview { get; set; } = true; internal bool QueryText { get; set; } internal bool RegEx { get; set; } internal bool EnvVar { get; set; } internal bool Updates { get; set; } = true; internal string Prefix { get; set; } internal string EverythingPath { get; set; } internal bool ShowMore { get; set; } = true; internal string CustomProgram { get; set; } = "notepad.exe"; internal string CustomArg { get; set; } = "$P"; internal LogLevel LoggingLevel { get; set; } = LogLevel.Error; public Dictionary Filters { get; } = []; } ``` -------------------------------- ### GetTranslatedPluginDescription() Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/api-reference/Main.md Retrieves the localized plugin description. This method is part of the IPluginI18n interface. ```APIDOC ## GetTranslatedPluginDescription() ### Description Get localized plugin description. This method is part of the IPluginI18n interface. ### Return Type `string` — Plugin description from resources ### Method Signature ```csharp public string GetTranslatedPluginDescription() ``` ``` -------------------------------- ### Windows Environment Variables for Path Resolution Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/configuration.md Common Windows environment variables used for resolving paths, particularly for the Everything executable. ```bash %PROGRAMFILES% → C:\ Program Files %PROGRAMFILES(X86)% → C:\ Program Files (x86) %LOCALAPPDATA% → C:\ Users\[User]\AppData\Local %USERPROFILE% → C:\ Users\[User] %TEMP% → C:\ Users\[User]\AppData\Local\Temp ``` -------------------------------- ### Dispose Method Source: https://github.com/lin-ycv/everythingpowertoys/blob/main/_autodocs/api-reference/Main.md Cleans up resources and cancels pending operations. It cancels in-flight queries, releases SDK resources, and prevents double-disposal. ```csharp public void Dispose() ```