### Send To Command Examples Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/configuration.md Examples of configuring the 'Send To' command for different applications like Notepad, VS Code, or 7-Zip. ```shell notepad.exe,$P$ # Send to Notepad ``` ```shell code.exe,$P$ # Send to VS Code ``` ```shell "C:\Program Files\7-Zip\7z.exe",x -o$($P$)\\ $P$ # Extract archive ``` -------------------------------- ### StartEverythingCommand Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/command-classes.md Represents a command to start the Everything service or open its download page if the executable is not found. ```APIDOC ## StartEverythingCommand ### Description Starts the Everything service or opens the download page if the executable is not found. ### Constructor `internal StartEverythingCommand()` ### Properties - **Name**: "" (empty) - **Icon**: `` ### Invoke Behavior 1. If the Everything executable is found, it launches the application. 2. If the Everything executable is not found, it opens `https://www.voidtools.com/` in the browser. 3. Returns `CommandResult.GoHome()`. ``` -------------------------------- ### GetItems Example Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/results-page.md Example of calling the GetItems method and logging the number of results returned. This demonstrates how to access the displayed items. ```csharp var resultsPage = new ResultsPage(); var items = resultsPage.GetItems(); Console.WriteLine($"Showing {items.Length} results"); ``` -------------------------------- ### Example: Displaying Errors from Everything SDK Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/query-and-search.md This example shows how to check if a search query returned null, indicating an error, and then display the error details to the user using `EverythingFailed()`. ```csharp var results = await Query.Search("test", token); if (results == null) { var errorItems = Query.EverythingFailed(); // Display error items to user } ``` -------------------------------- ### Complete Filters Configuration Example Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/configuration.md A comprehensive example demonstrating the definition of various filters including audio, video, documents, executables, archives, code, and project folders. ```toml # Audio files Audio: = ext:mp3;aac;flac;wav;wma;opus; # Video files Video: = ext:mp4;mkv;avi;mov;webm; # Documents Doc: = ext:pdf;docx;xlsx;pptx;txt; # Executables Exe: = ext:exe;bat;cmd;msi;ps1; # Archives Zip: = ext:7z;rar;zip;tar;gz; # Development Code: = ext:c;cpp;cs;h;hpp;java;js;py;ts;go;rs; # Project folders MyProjects: = C:\\Users\\username\\Documents\\Projects|C:\\Dev\\ ``` -------------------------------- ### Instantiate EverythingCmdPal Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/extension-entry-point.md Example of creating an instance of the EverythingCmdPal extension, passing a ManualResetEvent to its constructor. ```csharp ManualResetEvent disposedEvent = new(false); EverythingCmdPal extension = new(disposedEvent); // When extension is disposed, disposedEvent.Set() is called ``` -------------------------------- ### Data Flow Example Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/commands-provider.md Illustrates the data flow from Command Palette requesting a provider to the Everything SDK performing a search. ```csharp Command Palette ↓ EverythingCmdPal.GetProvider(ProviderType.Commands) ↓ CommandsProvider ├─→ TopLevelCommands() → [ResultsPage item, top 3 fallback results] └─→ FallbackCommands() → ["Show More" item] ↓ ResultsPage & FallbackSearchController ↓ Query.Search() [serialized via semaphore] ↓ Everything SDK (Everything2_x64.dll / Everything2_ARM64.dll) ``` -------------------------------- ### Initialize CommandsProvider Instance Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/commands-provider.md Example of creating and initializing a CommandsProvider instance. The provider is then ready to serve commands and search results. ```csharp var provider = new CommandsProvider(); // Provider is now ready to serve commands and search results ``` -------------------------------- ### Check Everything Version Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/settings-manager.md Indicates whether Everything 1.4 is installed. This property is determined by the result of Everything_GetMinorVersion(). ```csharp internal bool is1_4 { get; } ``` -------------------------------- ### Handle FallbackCommands Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/commands-provider.md Example demonstrating the retrieval of fallback commands. This usually results in a single 'Show More' item. ```csharp var provider = new CommandsProvider(); var fallbackItems = provider.FallbackCommands(); // Usually contains one "Show More" item ``` -------------------------------- ### Exe Property Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/settings-manager.md Gets the path to the Everything executable. The system attempts to auto-detect this path from the registry or standard installation locations. ```APIDOC ## Exe Property ### Description Specifies the path to the Everything executable. The system attempts to auto-detect this path if not explicitly provided. ### Type `string` ### Default Value Auto-detected from registry or standard installation paths ### Detection Order 1. `C:\Program Files\Everything 1.5a\Everything64.exe` 2. `C:\Program Files\Everything\Everything.exe` 3. `C:\Program Files (x86)\Everything 1.5\Everything.exe` 4. `C:\Program Files (x86)\Everything\Everything.exe` 5. Registry: `HKLM\SOFTWARE\...\Uninstall\Everything` → `InstallLocation` ### Example ```csharp if (!string.IsNullOrEmpty(settings.Exe)) { var proc = Process.Start(settings.Exe); } ``` ``` -------------------------------- ### Execute Everything Application Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/settings-manager.md Start the Everything application using the configured executable path. The path is auto-detected if not explicitly set. ```csharp if (!string.IsNullOrEmpty(settings.Exe)) { var proc = Process.Start(settings.Exe); } ``` -------------------------------- ### Send Command Configuration Examples Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/command-classes.md Illustrates different configuration formats for the SendCommand, specifying the executable and arguments. The $P$ placeholder is replaced with the file path. ```plaintext "notepad.exe,$P$" ``` ```plaintext "code.exe,$P$" ``` ```plaintext "7z.exe,x $P$" ``` -------------------------------- ### Instantiate ResultsPage Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/results-page.md Example of creating an instance of the ResultsPage class. This instance is then ready to process search queries. ```csharp var resultsPage = new ResultsPage(); // Now ready to handle search queries ``` -------------------------------- ### Example Everything Configuration File Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/configuration.md This JSON file configures various settings for the Everything Command Palette extension, such as sorting, maximum results, path matching, and executable paths. Ensure the path to 'Everything.exe' is correct for your system. ```json { "everything.SortOption": "14", "everything.Max": "50", "everything.Prefix": "", "everything.DetailPane": true, "everything.Match": false, "everything.Regex": false, "everything.RunAs": true, "everything.ShowMore": true, "everything.Exe": "C:\\Program Files\\Everything\\Everything.exe", "everything.EnableSend": true, "everything.Sendto": "notepad.exe,$P$", "everything.FilterPath": "C:\\Users\\username\\AppData\\Local\\Packages\\Microsoft.CmdPal_...\\LocalState" } ``` -------------------------------- ### Configuring Everything Executable Path Source: https://github.com/lin-ycv/everythingcommandpalette/wiki/Features Specifies the full path to the Everything executable. This is particularly relevant for the 'Show More' option and is pre-populated if Everything is installed in the default location. Otherwise, provide the complete path. ```text D:\\Everything\\Everything.exe ``` -------------------------------- ### UpdateQuery Example Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/results-page.md Example of directly setting a new search query using the UpdateQuery method. This can be used to apply specific filters or browse commands. ```csharp resultsPage.UpdateQuery("*.pdf ext:large"); ``` -------------------------------- ### Regex Search Examples Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/configuration.md Examples of regular expressions for advanced search queries when Regex is enabled. ```regex \.pdf$ # Files ending with .pdf ``` ```regex ^temp.*\.tmp$ # Temp files in temp folder ``` ```regex (doc|docx)$ # Word documents ``` -------------------------------- ### Display TopLevelCommands Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/commands-provider.md Example of how to retrieve and iterate through the top-level commands provided by CommandsProvider, printing each item's title. ```csharp var provider = new CommandsProvider(); var items = provider.TopLevelCommands(); foreach (var item in items) { Console.WriteLine($"{item.Title}"); } ``` -------------------------------- ### IExtension Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/types.md Interface implemented by `EverythingCmdPal` class. It provides methods to get providers and dispose of resources. ```APIDOC ## IExtension ### Description Interface implemented by `EverythingCmdPal` class. It provides methods to get providers and dispose of resources. ### Methods - `object? GetProvider(ProviderType providerType)`: Retrieves a provider based on its type. - `void Dispose()`: Releases resources held by the extension. ``` -------------------------------- ### UpdateSearchText Example Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/results-page.md Demonstrates calling UpdateSearchText with different search inputs. Due to debouncing, only the latest query ('test file') will be processed. ```csharp var resultsPage = new ResultsPage(); resultsPage.UpdateSearchText("", "test"); // User typed "test" resultsPage.UpdateSearchText("test", "test file"); // User typed " file" // Only "test file" query will execute ``` -------------------------------- ### BrowseCommand Example Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/command-classes.md Instantiates and invokes the BrowseCommand to change the search query to a specific folder path, displaying its contents. The command palette remains open after execution. ```csharp var cmd = new BrowseCommand("\"C:\\Users\\Documents\\\", resultsPage); cmd.Invoke(); // Changes search to show that folder's contents ``` -------------------------------- ### Dispose Example with Using Statement Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/results-page.md Demonstrates the correct way to dispose of a ResultsPage instance using a 'using' statement, ensuring all resources are cleaned up automatically. ```csharp using (var resultsPage = new ResultsPage()) { // Use page } // Dispose() called automatically ``` -------------------------------- ### StartEverythingCommand Class Definition Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/command-classes.md Defines the StartEverythingCommand class, which extends InvokableCommand. This command is used to start the Everything service or open its download page. ```csharp internal sealed partial class StartEverythingCommand : InvokableCommand ``` -------------------------------- ### Example RegEx Query in Everything Source: https://github.com/lin-ycv/everythingcommandpalette/wiki/Features Demonstrates how to use the `regex:` keyword in conjunction with other search terms to perform advanced filtering. This is useful when you need to apply regular expressions to your search queries without enabling the global RegEx feature. ```text audio: 101 regex:(\d{5}) ``` -------------------------------- ### RunAs Property Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/settings-manager.md Gets or sets a boolean value that enables the 'Run As' context menu item for executable files. ```APIDOC ## RunAs Property ### Description Determines whether the 'Run As' context menu option is available for executable files. ### Type `bool` ### Default Value `true` ### Example ```csharp if (settings.RunAs) { // Show "Run As Different User" option in context menu } ``` ``` -------------------------------- ### Accessing CommandsProvider Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/extension-entry-point.md Demonstrates how to get the CommandsProvider from the extension and retrieve top-level commands. Returns null if the provider type is not supported. ```csharp var extension = new EverythingCmdPal(disposedEvent); object? provider = extension.GetProvider(ProviderType.Commands); if (provider is CommandsProvider commandProvider) { var items = commandProvider.TopLevelCommands(); } ``` -------------------------------- ### Result Class Disposal Examples Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/result.md Demonstrates correct and manual ways to call the Dispose() method on a Result object to release resources. Always call Dispose() when a Result is no longer needed. ```csharp // Correct usage using (var result = new Result()) { // Use result } // Dispose() called automatically // Manual disposal var result = new Result(); try { // Use result } finally { result.Dispose(); } // In containers foreach (var result in results) { result.Dispose(); } results.Clear(); ``` -------------------------------- ### EverythingCmdPal Class Signature Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/extension-entry-point.md Defines the main extension class, EverythingCmdPal, which implements IExtension and IDisposable. It is marked as sealed and has a unique GUID for COM registration. ```csharp [Guid("bc2fb4e5-eadc-4073-a7fd-ae5d44796190")] public sealed partial class EverythingCmdPal : IExtension, IDisposable ``` -------------------------------- ### Process Launch Configuration for Helper.exe Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/win32-helper.md Configures ProcessStartInfo to launch Helper.exe with necessary settings for output redirection and hiding the window. UseShellExecute must be false for redirection. ```csharp string exe = Path.Combine(AppContext.BaseDirectory, "Win32", "Helper.exe"); var psi = new ProcessStartInfo(exe) { Arguments = $"\"{fullPath}\" {arg}", RedirectStandardOutput = true, RedirectStandardError = true, UseShellExecute = false, // Must be false for redirection CreateNoWindow = true // Don't show window }; ``` -------------------------------- ### Everything_GetMinorVersion Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/native-methods.md Get the minor version number of the Everything SDK. This is useful for feature detection and ensuring compatibility. ```APIDOC ## Everything_GetMinorVersion ### Description Get Everything SDK version (minor version number). ### Method Signature ```csharp [DllImport(dllName)] internal static extern uint Everything_GetMinorVersion(); ``` ### Returns - **uint** - Minor version (e.g., 4 for 1.4, 5 for 1.5) ### Used For Feature detection (filters only available in 1.4+) ### Request Example ```csharp if (Everything_GetMinorVersion() < 5) { // Everything 1.4 is installed loadCustomFilters(); } ``` ``` -------------------------------- ### ProcessStartInfo Configuration with Shell Verbs Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/shell-helper.md Configure ProcessStartInfo for launching processes using shell verbs. Ensure UseShellExecute is true for verb integration and elevation. ```csharp ProcessStartInfo startInfo = new() { Arguments = string.IsNullOrEmpty(args) ? string.Empty : args, FileName = path, UseShellExecute = true, // Required for verbs and shell integration Verb = verb, // Shell verb (runAs, runAsUser, etc.) WorkingDirectory = dir ?? "", // Set if provided }; ``` -------------------------------- ### StartEverythingCommand Constructor Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/command-classes.md Default constructor for the StartEverythingCommand. It does not require any parameters. ```csharp internal StartEverythingCommand() ``` -------------------------------- ### Configure Everything Executable Path Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/configuration.md Specify the path to the Everything executable. Auto-detection is attempted if not explicitly set. ```json { "everything.Exe": "C:\\Program Files\\Everything\\Everything.exe" } ``` -------------------------------- ### Get Result Size Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/native-methods.md Retrieves the size of a specific result in bytes. A helper method is provided to convert this size to kilobytes. ```csharp [DllImport(dllName)] internal static extern bool Everything_GetResultSize(uint dwIndex, ref long lpSize); ``` ```csharp internal static long EPT_GetSizeKB(uint i) { long size = default; Everything_GetResultSize(i, ref size); return size / 1024; // Convert to KB } ``` -------------------------------- ### Process Launching with Exception Handling Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/shell-helper.md Launch a process using configured ProcessStartInfo and handle potential exceptions. Logs errors and returns a boolean indicating success or failure. ```csharp try { AllowSetForegroundWindow(ASFW_ANY); Process.Start(startInfo); return true; } catch (Exception e) { msg = e.Message; ExtensionHost.LogMessage($"ECP: Failed to launch: {e.Message}"); return false; } ``` -------------------------------- ### Get Result Path Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/native-methods.md Retrieves the directory path of a specific result by its index. The returned pointer must be marshaled to a string. ```csharp [DllImport(dllName, CharSet = CharSet.Unicode)] internal static extern IntPtr Everything_GetResultPathW(uint dwIndex); ``` ```csharp string path = Marshal.PtrToStringUni(Everything_GetResultPathW(0)); ``` -------------------------------- ### Get Result File Name Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/native-methods.md Retrieves the filename of a specific result by its index. The returned pointer must be marshaled to a string. ```csharp [DllImport(dllName, CharSet = CharSet.Unicode)] internal static extern IntPtr Everything_GetResultFileNameW(uint dwIndex); ``` ```csharp string fileName = Marshal.PtrToStringUni(Everything_GetResultFileNameW(0)); ``` -------------------------------- ### Get Number of Results Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/native-methods.md Retrieves the total count of items returned by the last search query. Use this to iterate through results. ```csharp [DllImport(dllName)] internal static extern uint Everything_GetNumResults(); ``` ```csharp for (uint i = 0; i < Everything_GetNumResults(); i++) { // Process result i } ``` -------------------------------- ### SortOption Property Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/settings-manager.md Gets the sort order for search results. This property returns an integer value corresponding to the Sort enum. ```APIDOC ## SortOption Property ### Description Represents the sort order for search results. The value corresponds to an enum cast to an integer. ### Type `int` (corresponds to `Sort` enum) ### Default Value `14` (DATE_MODIFIED_DESCENDING) ### Available Options - `1`: NAME_ASCENDING - `2`: NAME_DESCENDING - `3`: PATH_ASCENDING - `4`: PATH_DESCENDING - `5`: SIZE_ASCENDING - `6`: SIZE_DESCENDING - `7`: EXTENSION_ASCENDING - `8`: EXTENSION_DESCENDING - `9`: TYPE_NAME_ASCENDING - `10`: TYPE_NAME_DESCENDING - `11`: DATE_CREATED_ASCENDING - `12`: DATE_CREATED_DESCENDING - `13`: DATE_MODIFIED_ASCENDING - `14`: DATE_MODIFIED_DESCENDING (default) - `15–26`: Additional sorting options ### Example ```csharp if (settings.SortOption == 14) { Console.WriteLine("Results are sorted by modified date, newest first"); } ``` ``` -------------------------------- ### Initialize Result Object Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/result.md Demonstrates the basic instantiation of a Result object and setting its core file properties. This is typically done internally by the search process. ```csharp var result = new Result(); result.FileName = "document.pdf"; result.FilePath = "C:\\Users\\Documents"; ``` -------------------------------- ### Launch Process with ShellExecute Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/shell-helper.md Use this method to launch a process or file with optional arguments, working directory, and shell verb. It returns true on success and false on exception, providing an error message via the 'msg' parameter. ```csharp internal static bool OpenInShell( string path, ref string msg, string? args = null, string? dir = null, string verb = "") ``` ```csharp string errorMsg = ""; bool success = ShellHelper.OpenInShell( "notepad.exe", ref errorMsg, args: "C:\\file.txt", dir: "C:\\Documents" ); if (!success) { Console.WriteLine($"Failed: {errorMsg}"); } ``` -------------------------------- ### TOML File Format Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/configuration.md Defines the basic structure for filter configuration files using TOML syntax. Comments start with '#'. ```toml # Comment line (starts with #) FilterName: = FilterDefinition; ``` -------------------------------- ### ShowMoreCommand Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/command-classes.md Represents a command to open the Everything application and display the full search result set for a given query. ```APIDOC ## ShowMoreCommand ### Description Opens the Everything application to show the full result set for the current search query. ### Constructor `internal ShowMoreCommand(string query, string exe)` #### Parameters - **query** (string) - Required - Current search query - **exe** (string) - Required - Path to Everything executable ### Properties - **Name**: "Show More..." (localized) - **Icon**: `` ### Invoke Behavior 1. Launches the Everything application. 2. Passes the current query as an argument: `-s "{query}"`. 3. The Everything application opens with the same search results. 4. Returns `CommandResult.Dismiss()`. ``` -------------------------------- ### Get Last Error Code Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/native-methods.md Retrieve the error code from the last operation. This is useful for diagnosing issues, such as the Everything service not running. ```csharp [DllImport(dllName)] internal static extern uint Everything_GetLastError(); ``` ```csharp if (!Everything_QueryW(true)) { uint error = Everything_GetLastError(); if (error == (uint)EverythingErrors.EVERYTHING_ERROR_IPC) { Console.WriteLine("Everything service is not running"); } } ``` -------------------------------- ### ShowMore Property Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/settings-manager.md Gets or sets a boolean value that controls the display of a 'Show More' button, which opens Everything with the full result set. ```APIDOC ## ShowMore Property ### Description Controls the visibility of the 'Show More' button, which allows users to open the full set of search results in the Everything application. ### Type `bool` ### Default Value `true` ### Example ```csharp if (settings.ShowMore) { // Add "Show More" button to results } ``` ``` -------------------------------- ### Send File to Configured Application Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/command-handler.md Sends a file to a configured application, with Notepad as the default. The `settings.Sendto` configuration specifies the executable and arguments, using `$P$` as a placeholder for the file path. ```javascript SendCommand(fullPath, settings.Sendto) ``` -------------------------------- ### Regex Property Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/settings-manager.md Gets or sets a boolean value that enables regular expression queries, allowing search terms to be interpreted as patterns. ```APIDOC ## Regex Property ### Description Enables or disables the interpretation of search queries as regular expressions. ### Type `bool` ### Default Value `false` ### Behavior - When `false`: treats query as literal text - When `true`: interprets query as regex pattern ### Example ```csharp // With Regex=true: "\.pdf$" matches only PDF files ``` ``` -------------------------------- ### Configuring Send to Program Path and Arguments Source: https://github.com/lin-ycv/everythingcommandpalette/wiki/Features Defines the path to an executable and its arguments for the 'Send to specified' command. The placeholder $P$ will be replaced with the full path of the selected search result. Consult the target program's documentation for argument handling. ```text $P$ ``` -------------------------------- ### Max Property Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/settings-manager.md Gets the maximum number of search results to return from Everything. This is a uint value with a valid range from 1 to 65535. ```APIDOC ## Max Property ### Description Specifies the maximum number of search results to return from the Everything search. ### Type `uint` ### Default Value `10` ### Valid Range `1`–`65535` ### Example ```csharp // Shows top 50 results var settings = new SettingsManager { Max = 50 }; ``` ``` -------------------------------- ### Get Result Extension Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/native-methods.md Retrieves the file extension of a specific result, including the leading dot. The returned pointer must be marshaled to a string. ```csharp [DllImport(dllName, CharSet = CharSet.Unicode)] internal static extern IntPtr Everything_GetResultExtensionW(uint dwIndex); ``` ```csharp string ext = Marshal.PtrToStringUni(Everything_GetResultExtensionW(0)); // Returns ".pdf", ".txt", etc. ``` -------------------------------- ### Enable Run As User Option Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/configuration.md Control the visibility of the 'Run As Different User' context menu option. ```json { "everything.RunAs": true } ``` -------------------------------- ### Match Property Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/settings-manager.md Gets or sets a boolean value that enables path matching in queries, allowing searches to include both the filename and the full path. ```APIDOC ## Match Property ### Description Enables or disables path matching for search queries. When enabled, searches consider both the filename and the full path. ### Type `bool` ### Default Value `false` ### Behavior - When `false`: searches filename only - When `true`: searches full path (Everything: `match-path`) ### Example ```csharp // With Match=false: "test" finds "test.txt" but not "C:\test\file.txt" // With Match=true: "test" finds both ``` ``` -------------------------------- ### CommandsProvider Constructor Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/commands-provider.md Instantiates a new CommandsProvider. Initialization includes setting IDs, loading icons, attaching settings, and preparing the fallback search controller. ```csharp public CommandsProvider() ``` -------------------------------- ### Run Command Prompt in Directory Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/shell-helper.md Use this to launch a new Command Prompt instance with a specified working directory. This is useful for running commands within a particular project or folder context. ```csharp string error = ""; ShellHelper.OpenInShell( "cmd.exe", ref error, dir: "C:\\MyProject" ); // Opens cmd with working directory C:\MyProject ``` -------------------------------- ### Initialize CommandHandler Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/command-handler.md Creates a new instance of the CommandHandler. This is used to set up predefined executable extensions for 'Run as Admin' detection. ```csharp var handler = new CommandHandler(); ``` -------------------------------- ### Get SDK Minor Version Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/native-methods.md Retrieve the minor version number of the Everything SDK. This can be used for feature detection, as some filters are only available in later versions. ```csharp [DllImport(dllName)] internal static extern uint Everything_GetMinorVersion(); ``` ```csharp if (Everything_GetMinorVersion() < 5) { // Everything 1.4 is installed loadCustomFilters(); } ``` -------------------------------- ### Configure Send To Application Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/settings-manager.md Specifies the executable and arguments for the 'Send To' command. The $P$ placeholder is replaced with the file path. Defaults to notepad.exe. ```csharp public string Sendto { get; } ``` ```csharp settings.Sendto = "notepad.exe,$P$"; // Or open with specific app settings.Sendto = "code.exe,$P$"; // Send to VS Code ``` -------------------------------- ### BrowseCommand Constructor Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/command-classes.md Defines the BrowseCommand with its search query and results page parameters. Use this to create a command that updates search results to show folder contents. ```csharp internal sealed partial class BrowseCommand(string q, DynamicListPage p) : InvokableCommand ``` -------------------------------- ### Get Result Date Modified Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/native-methods.md Retrieves the last modified date of a specific result. A helper method is provided to format this date into a readable string. ```csharp [DllImport(dllName)] internal static extern bool Everything_GetResultDateModified( uint dwIndex, ref FILETIME lpDateModified); ``` ```csharp internal static string EPT_GetModifiedDateTime(uint i) { FILETIME ft = new(); Everything_GetResultDateModified(i, ref ft); var dt = DateTime.FromFileTime( ((long)ft.dwHighDateTime << 32) | ft.dwLowDateTime ).ToLocalTime(); return dt.ToString("yyyy-MM-dd hh:mm tt", CultureInfo.InvariantCulture); } ``` -------------------------------- ### Prefix Property Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/settings-manager.md Gets or sets a search prefix that is automatically prepended to all queries. This can be used to restrict searches to specific directories or add persistent filters. ```APIDOC ## Prefix Property ### Description Defines a search prefix that is automatically added to the beginning of every query. This is useful for narrowing searches to specific paths or applying consistent filters. ### Type `string` ### Default Value Empty string ### Use Cases - Restrict searches to specific directory: `"C:\Users\username\"` - Add persistent filter: `"ext:txt "` ### Example ```csharp // All queries start with "C:\Projects\ " settings.Prefix = "C:\Projects\ "; ``` ``` -------------------------------- ### Enable Path Matching Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/configuration.md Determine whether to search only filenames or both filenames and full paths. Set to true to include path matching. ```json { "everything.Match": false } ``` -------------------------------- ### ShowMoreCommand Constructor Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/command-classes.md Constructor for the ShowMoreCommand. It requires the current search query and the path to the Everything executable. ```csharp internal ShowMoreCommand(string query, string exe) ``` -------------------------------- ### Using Statement for Disposal Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/extension-entry-point.md Example of using a 'using' statement to ensure the EverythingCmdPal extension is properly disposed of, which automatically calls Dispose() and sets the disposal event. ```csharp using (EverythingCmdPal extension = new(disposedEvent)) { // Use extension } // Dispose() is called automatically, setting disposedEvent ``` -------------------------------- ### EverythingCmdPal Constructor Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/extension-entry-point.md Initializes the EverythingCmdPal extension. Requires a ManualResetEvent to signal when the extension is disposed, coordinating shutdown with the COM server. ```csharp public EverythingCmdPal(ManualResetEvent extensionDisposedEvent) ``` -------------------------------- ### Execution and Error Handling of Helper.exe Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/win32-helper.md Launches the configured process, captures standard error, waits for completion, and logs errors if the exit code is non-zero. Errors are logged with file path and stderr output. ```csharp using var process = Process.Start(psi); string error = process.StandardError.ReadToEnd(); process.WaitForExit(); if (process.ExitCode != 0) ExtensionHost.LogMessage( $"EPT-CP: {Resources.clipboard_failed}\\n{fullPath}\\n{error}" ); ``` -------------------------------- ### Set Sort Order for Results Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/native-methods.md Set the sort order for search results using an enum value. Examples show descending order by date modified and size. ```csharp [DllImport(dllName)] internal static extern void Everything_SetSort(Sort SortType); ``` ```csharp Everything_SetSort(Sort.DATE_MODIFIED_DESCENDING); Everything_SetSort(Sort.SIZE_DESCENDING); ``` -------------------------------- ### Apply Runtime Settings Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/configuration.md Call these functions on SettingsManager.SaveSettings() to apply configuration changes to the Everything SDK. Ensure correct types are used for parameters. ```csharp Everything_SetSort((Sort)SortOption); Everything_SetMax(Max); Everything_SetMatchPath(Match); Everything_SetRegex(Regex); if (is1_4) CheckFilters(); ``` -------------------------------- ### Handle Everything SDK Errors Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/query-and-search.md Call this method when an Everything SDK query fails to get a list of items describing the error. This is useful for providing user-friendly error messages. ```csharp internal static List EverythingFailed() { } ``` -------------------------------- ### SettingsManager Constructor Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/settings-manager.md Initializes the SettingsManager, detecting the Everything SDK version, setting default settings, loading persisted settings, synchronizing with the Everything SDK, and loading filter definitions. ```APIDOC ## SettingsManager Constructor ### Description Initializes the SettingsManager, which manages user-configurable options for the Everything Command Palette extension. It handles persistent storage, settings synchronization with the Everything SDK, and filter configuration. ### Code Example ```csharp var settingsManager = new SettingsManager(); Console.WriteLine($"Max results: {settingsManager.Max}"); Console.WriteLine($"Search prefix: {settingsManager.Prefix}"); ``` ``` -------------------------------- ### Get Settings JSON File Path Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/settings-manager.md Retrieves the full path to the application's settings JSON file. This path is typically located within the user's LocalAppData directory. ```csharp internal static string SettingsJsonPath() { // ... implementation details ... return "%LocalAppData%\\Microsoft.CmdPal\\everything.json"; } ``` ```csharp string path = SettingsManager.SettingsJsonPath(); Console.WriteLine($"Settings file: {path}"); ``` -------------------------------- ### Select Native DLL based on Architecture Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/native-methods.md Determines which Everything SDK DLL to load based on the system's architecture (x64 or ARM64). ```csharp #if ARM64 internal const string dllName = "Everything2_ARM64.dll"; #else internal const string dllName = "Everything2_x64.dll"; #endif ``` -------------------------------- ### DetailPane Property Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/settings-manager.md Gets a boolean value indicating whether to display the file details pane in the search results, showing information like size, type, modified date, and icon. ```APIDOC ## DetailPane Property ### Description Determines whether the file details pane (showing size, type, modified date, icon) is displayed in the search results. ### Type `bool` ### Default Value `true` ### Example ```csharp if (settings.DetailPane) { // Show detailed file information in UI } ``` ``` -------------------------------- ### EverythingCmdPal Constructor Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/extension-entry-point.md Initializes the EverythingCmdPal extension. It requires a ManualResetEvent to signal when the extension is disposed, coordinating shutdown with the COM server. ```APIDOC ## EverythingCmdPal Constructor ### Description Initializes the EverythingCmdPal extension, requiring a `ManualResetEvent` to signal its disposal. ### Signature ```csharp public EverythingCmdPal(ManualResetEvent extensionDisposedEvent) ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **extensionDisposedEvent** (ManualResetEvent) - Required - Event that signals when the extension is disposed, used to coordinate shutdown with the COM server. ### Request Example ```csharp ManualResetEvent disposedEvent = new(false); EverythingCmdPal extension = new(disposedEvent); ``` ### Response None ``` -------------------------------- ### OpenConsoleCommand Constructor Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/command-classes.md Constructor for the OpenConsoleCommand. It takes the full path and a boolean indicating if the target is a folder. ```csharp internal OpenConsoleCommand(string fullPath, bool isFolder) ``` -------------------------------- ### Show Open With Dialog Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/shell-helper.md Use this to display the 'Open With' dialog for a file, allowing the user to choose an application to open it. This is useful when the default application is not desired or needs to be changed. ```csharp string error = ""; ShellHelper.OpenInShell( "C:\\file.txt", ref error, verb: "openas" ); // Shows "Open With" application chooser ``` -------------------------------- ### Load Context Menu Commands Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/command-handler.md Loads all applicable context menu commands for a given file or folder path. Specify if the path is a folder and provide the results page for the browse command. ```csharp var commands = handler.LoadCommands("C:\\file.exe", isFolder: false, page); ``` -------------------------------- ### Initialize SemaphoreSlim for SDK Access Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/query-and-search.md Initializes a SemaphoreSlim to ensure thread-safe access to the Everything SDK. This is crucial as the SDK uses global process state and is not thread-safe. ```csharp private static readonly SemaphoreSlim _sdkGate = new(1, 1); ``` -------------------------------- ### Handle IPC Errors in Everything SDK Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/errors.md This code snippet demonstrates special handling for IPC errors, which occur when the Everything service is not running. It displays a specific error message, a status message, and provides a 'Start Everything' action. ```csharp if (lastError == (uint)EverythingErrors.EVERYTHING_ERROR_IPC) { items.Add(new ListItem(new StartEverythingCommand()) { Title = message, Subtitle = $"0x{lastError:X8}", }); ExtensionHost.ShowStatus( new StatusMessage() { Message = Resources.everything_not_running, State = MessageState.Error }, StatusContext.Page ); } ``` -------------------------------- ### OpenWithCommand Constructor Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/command-classes.md Constructor for the OpenWithCommand class. Requires the full path to the file that will be opened. ```csharp internal OpenWithCommand(string fullPath) ``` -------------------------------- ### Search (Full Results) Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/query-and-search.md Executes a full search using the Everything SDK with all configured options, including asynchronous thumbnail loading. This method is suitable for retrieving comprehensive search results. ```APIDOC ## Search (Full Results) ### Description Executes a full search with all configured options, including thumbnail loading. ### Method `Search` ### Signature `static async Task> Search(string query, CancellationToken token)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters Table | Parameter | Type | Required | Description | |-----------|------|----------|-------------| | query | string | Yes | Search query string | | token | CancellationToken | Yes | Cancellation token for aborting the search | ### Returns `Task>` — Awaitable task yielding list of `Result` objects or null on error ### Behavior 1. Acquires semaphore lock (serializes Everything SDK access) 2. Applies configured search prefix (if set) 3. Applies filter transformations (for Everything 1.4) 4. Calls Everything SDK `Everything_QueryW()` 5. For each result, marshals native data: Filename, path, extension, File size (in KB), Modified date and time, Folder indicator, File type description 6. Loads thumbnail asynchronously (if enabled) 7. Returns results or error list ### Example ```csharp using var cts = new CancellationTokenSource(); var results = await Query.Search("*.pdf", cts.Token); if (results != null) { Console.WriteLine($"Found {results.Count} PDF files"); foreach (var result in results) { Console.WriteLine($" {result.FileName} in {result.FilePath}"); } } else { Console.WriteLine("Search failed"); } ``` ``` -------------------------------- ### Win32Helper.Execute Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/win32-helper.md Executes a Win32 operation (copy, delete, clipboard access) by launching Helper.exe with specified arguments. This method is internal and intended for use within the application's helper utilities. ```APIDOC ## Win32Helper.Execute ### Description Executes a Win32 operation through Helper.exe. This method is used for privileged operations that require UI thread context or special permissions. ### Method Signature `internal static void Execute(string fullPath, string arg)` ### Parameters #### Path Parameters - **fullPath** (string) - Required - Full path to file or folder to operate on. - **arg** (string) - Required - Operation flag. Accepted values are "--copy", "--as-text", or "--delete". ### Returns `void` - This method does not return an error code. Errors are handled by throwing exceptions or logging messages. ### Behavior 1. Locates Helper.exe in `{ExtensionDirectory}/Win32/Helper.exe`. 2. Launches Helper.exe with the provided `fullPath` and `arg` as arguments. 3. Captures standard output and standard error streams from the Helper.exe process. 4. Waits for the Helper.exe process to complete. 5. Logs an error message if the Helper.exe process exits with a non-zero exit code, including the file path and any error output. ### Example ```csharp Win32Helper.Execute("C:\\file.txt", "--copy"); Win32Helper.Execute("C:\\file.txt", "--as-text"); Win32Helper.Execute("C:\\file.txt", "--delete"); ``` ``` -------------------------------- ### TopLevelCommands Method Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/commands-provider.md Retrieves the top-level command items to be displayed when the Everything extension is selected in the Command Palette. ```APIDOC ## TopLevelCommands() ### Description Returns the top-level command items displayed when the extension is selected in Command Palette. ### Method `public override ICommandItem[] TopLevelCommands()` ### Returns `ICommandItem[]` — Array of command items to display. ### Contents 1. Main results list item (the Everything search results page) 2. Top 3 fallback search results (from the fallback controller) ### Example ```csharp var provider = new CommandsProvider(); var items = provider.TopLevelCommands(); foreach (var item in items) { Console.WriteLine($"{item.Title}"); } ``` ``` -------------------------------- ### Open File with Default Application Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/shell-helper.md Use this to open a file using its default associated application. Ensure the file path is correctly specified. ```csharp string error = ""; ShellHelper.OpenInShell("C:\\document.pdf", ref error); // Opens PDF in default reader ``` -------------------------------- ### Open File with Application Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/command-handler.md Opens the 'Open With' dialog to allow the user to choose an application for a file. Applies to files only. ```javascript OpenWithCommand(fullPath) ``` -------------------------------- ### Initialize SettingsManager Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/settings-manager.md Instantiate the SettingsManager to load and manage extension settings. Accesses properties like Max and Prefix after initialization. ```csharp var settingsManager = new SettingsManager(); Console.WriteLine($"Max results: {settingsManager.Max}"); Console.WriteLine($"Search prefix: {settingsManager.Prefix}"); ``` -------------------------------- ### Initialize SettingsManager Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/query-and-search.md A global SettingsManager instance is available for accessing user configurations like search prefixes, filters, and sorting options. ```csharp internal static readonly SettingsManager Settings = new(); ``` -------------------------------- ### Allowing Foreground Window Activation Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/shell-helper.md Grant permission for a newly launched process to set the foreground window. This is necessary for background COM servers. ```csharp const int ASFW_ANY = -1; // Allow any process to set foreground [DllImport("user32.dll", SetLastError = true)] private static extern bool AllowSetForegroundWindow(int dwProcessId); // Before launching: AllowSetForegroundWindow(ASFW_ANY); ``` -------------------------------- ### Open Explorer at Specific Path Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/shell-helper.md Use this to open Windows Explorer at a specific directory and select a particular file. The `args` parameter is used to specify the file to select, and `dir` sets the working directory. ```csharp string error = ""; ShellHelper.OpenInShell( "explorer.exe", ref error, args: "/select,\"C:\\file.txt\"", dir: "C:\\folder" ); // Opens Explorer with file.txt selected ``` -------------------------------- ### CommandsProvider Constructor Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/commands-provider.md Initializes a new instance of the CommandsProvider class. This constructor sets up the provider with default configurations for integrating with the Command Palette and Everything search. ```APIDOC ## CommandsProvider() ### Description Initializes a new instance of the CommandsProvider class. ### Parameters None ### Initialization Details - Sets `Id` to "Everything" - Sets `DisplayName` to "Everything" - Loads icon from `Assets\EverythingPT.svg` - Attaches settings manager from `Query.Settings` - Sets `Frozen = false` to enable dynamic item updates - Creates a results list item with subtitle from resources - Initializes fallback search controller ### Example ```csharp var provider = new CommandsProvider(); // Provider is now ready to serve commands and search results ``` ``` -------------------------------- ### Serialize SDK Access with SemaphoreSlim Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/query-and-search.md Acquires and releases a SemaphoreSlim to serialize access to the Everything SDK's search methods. This ensures only one caller can use the SDK at a time, queuing multiple requests. ```csharp await _sdkGate.WaitAsync(token); try { return await SearchCore(query, token, ...); } finally { _sdkGate.Release(); } ``` -------------------------------- ### Configure Filter Path (Everything 1.4) Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/configuration.md Specify the directory where the `filters.toml` file is located. This is only applicable for Everything version 1.4. ```json { "everything.FilterPath": "C:\\Users\\username\\AppData\\Local\\Packages\\Microsoft.CmdPal_..._LocalState" } ``` -------------------------------- ### OpenFolderCommand Constructor Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/command-classes.md Constructor for the OpenFolderCommand class. Accepts the full path to a file or folder. ```csharp internal OpenFolderCommand(string fullname) ``` -------------------------------- ### Run Executable as Different User Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/shell-helper.md Use this to launch an application and prompt the user to enter credentials for a different user account. This is useful for running tasks with specific user permissions. ```csharp string error = ""; ShellHelper.OpenInShell( "C:\\app.exe", ref error, verb: "runAsUser" ); // Shows "Run As Different User" dialog ``` -------------------------------- ### Enable Show More Button Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/configuration.md Determine whether to display the 'Show More' button in the search results, which opens the Everything application. ```json { "everything.ShowMore": true } ``` -------------------------------- ### PropertiesCommand Constructor Source: https://github.com/lin-ycv/everythingcommandpalette/blob/main/_autodocs/api-reference/command-classes.md Constructor for the PropertiesCommand. Requires the full path to the file or folder whose properties are to be displayed. ```csharp internal PropertiesCommand(string fullname) ```