From e583ebf872d9e3f5fd0421c7a46f198205824ed6 Mon Sep 17 00:00:00 2001 From: "Lin Yu-Chieh (Victor)" Date: Wed, 9 Mar 2022 00:39:34 +0800 Subject: [PATCH] Fixes #5 Updated to NET 6 Fixed #5 - fatal error when disabling --- ...ity.PowerToys.Run.Plugin.Everything.csproj | 250 +++++----- ContextMenuLoader.cs | 362 +++++++------- Main.cs | 415 ++++++++-------- NativeMethods.cs | 465 +++++++++--------- Properties/Resources.Designer.cs | 396 +++++++-------- Properties/Resources.resx | 328 ++++++------ README.md | 18 +- SearchHelper/SearchResult.cs | 30 +- plugin.json | 24 +- 9 files changed, 1146 insertions(+), 1142 deletions(-) diff --git a/Community.PowerToys.Run.Plugin.Everything.csproj b/Community.PowerToys.Run.Plugin.Everything.csproj index 0147245..3e1f1b8 100644 --- a/Community.PowerToys.Run.Plugin.Everything.csproj +++ b/Community.PowerToys.Run.Plugin.Everything.csproj @@ -1,127 +1,123 @@ - - - - - net5.0-windows - {64467D32-4786-4ADD-9B77-FBF3C965D3D1} - Properties - Community.PowerToys.Run.Plugin.Everything - Community.PowerToys.Run.Plugin.Everything - $([System.IO.File]::ReadAllText('$(MSBuildThisFileDirectory)plugin.json').Split(',')[5].Split(':')[1].Trim().Trim('"')) - true - false - false - x64 - en-US - Yu Chieh (Victor) Lin - false - - true - - - - true - ..\..\..\..\..\x64\Debug\modules\launcher\Plugins\Everything\ - DEBUG;TRACE - full - x64 - 7.3 - prompt - MinimumRecommendedRules.ruleset - 4 - false - true - - - - ..\..\..\..\..\x64\Release\modules\launcher\Plugins\Everything\ - TRACE - true - none - x64 - 7.3 - prompt - MinimumRecommendedRules.ruleset - 4 - true - false - Auto - - - - - GlobalSuppressions.cs - - - StyleCop.json - - - - - - false - false - - - false - false - - - - - - PreserveNewest - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - True - True - Resources.resx - - - - - - PublicResXFileCodeGenerator - Resources.Designer.cs - - - - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - - - - - - + + + + + net6.0-windows + {64467D32-4786-4ADD-9B77-FBF3C965D3D1} + Properties + Community.PowerToys.Run.Plugin.Everything + Community.PowerToys.Run.Plugin.Everything + $([System.IO.File]::ReadAllText('$(MSBuildThisFileDirectory)plugin.json').Split(',')[5].Split(':')[1].Trim().Trim('"')) + true + false + false + x64 + en-US + Yu Chieh (Victor) Lin + + + + true + ..\..\..\..\..\x64\Debug\modules\launcher\Plugins\Everything\ + DEBUG;TRACE + full + x64 + 7.3 + prompt + MinimumRecommendedRules.ruleset + 4 + false + true + + + + ..\..\..\..\..\x64\Release\modules\launcher\Plugins\Everything\ + TRACE + true + pdbonly + x64 + 7.3 + prompt + MinimumRecommendedRules.ruleset + 4 + true + + + + + GlobalSuppressions.cs + + + StyleCop.json + + + + + + false + + + false + + + + + + PreserveNewest + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + True + True + Resources.resx + + + + + + PublicResXFileCodeGenerator + Resources.Designer.cs + + + + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + + + + + + diff --git a/ContextMenuLoader.cs b/ContextMenuLoader.cs index 704b670..ca55f97 100644 --- a/ContextMenuLoader.cs +++ b/ContextMenuLoader.cs @@ -1,181 +1,181 @@ -// Copyright (c) Microsoft Corporation -// The Microsoft Corporation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections.Generic; -using System.IO; -using System.IO.Abstractions; -using System.Reflection; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Input; -using Wox.Infrastructure; -using Wox.Plugin; -using Wox.Plugin.Logger; - -namespace Community.PowerToys.Run.Plugin.Everything -{ - internal class ContextMenuLoader : IContextMenu - { - private readonly PluginInitContext _context; - - // Extensions for adding run as admin context menu item for applications - private readonly string[] appExtensions = { ".exe", ".bat", ".appref-ms", ".lnk" }; - - public ContextMenuLoader(PluginInitContext context) - { - _context = context; - } - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "We want to keep the process alive, and instead log and show an error message")] - public List LoadContextMenus(Result selectedResult) - { - var contextMenus = new List(); - if (selectedResult.ContextData is SearchResult record) - { - bool isFile = Path.HasExtension(record.Path); - - if (isFile) - { - contextMenus.Add(CreateOpenContainingFolderResult(record)); - } - - // Test to check if File can be Run as admin, if yes, we add a 'run as admin' context menu item - if (CanFileBeRunAsAdmin(record.Path)) - { - contextMenus.Add(CreateRunAsAdminContextMenu(record)); - } - - contextMenus.Add(new ContextMenuResult - { - PluginName = Assembly.GetExecutingAssembly().GetName().Name, - Title = Properties.Resources.copy_path, - Glyph = "\xE8C8", - FontFamily = "Segoe MDL2 Assets", - AcceleratorKey = Key.C, - AcceleratorModifiers = ModifierKeys.Control, - - Action = (context) => - { - try - { - Clipboard.SetText(record.Path); - return true; - } - catch (Exception e) - { - var message = Properties.Resources.clipboard_failed; - Log.Exception(message, e, GetType()); - - _context.API.ShowMsg(message); - return false; - } - }, - }); - contextMenus.Add(new ContextMenuResult - { - PluginName = Assembly.GetExecutingAssembly().GetName().Name, - Title = Properties.Resources.open_in_console, - Glyph = "\xE756", - FontFamily = "Segoe MDL2 Assets", - AcceleratorKey = Key.C, - AcceleratorModifiers = ModifierKeys.Control | ModifierKeys.Shift, - - Action = (context) => - { - try - { - if (isFile) - { - Helper.OpenInConsole(Path.GetDirectoryName(record.Path)); - } - else - { - Helper.OpenInConsole(record.Path); - } - - return true; - } - catch (Exception e) - { - Log.Exception($"Failed to open {record.Path} in console, {e.Message}", e, GetType()); - return false; - } - }, - }); - } - - return contextMenus; - } - - // Function to add the context menu item to run as admin - [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "We want to keep the process alive, and instead log the exception message")] - private static ContextMenuResult CreateRunAsAdminContextMenu(SearchResult record) - { - return new ContextMenuResult - { - PluginName = Assembly.GetExecutingAssembly().GetName().Name, - Title = Properties.Resources.run_as_admin, - Glyph = "\xE7EF", - FontFamily = "Segoe MDL2 Assets", - AcceleratorKey = Key.Enter, - AcceleratorModifiers = ModifierKeys.Control | ModifierKeys.Shift, - Action = _ => - { - try - { - Task.Run(() => Helper.RunAsAdmin(record.Path)); - return true; - } - catch (Exception e) - { - Log.Exception($"Failed to run {record.Path} as admin, {e.Message}", e, MethodBase.GetCurrentMethod().DeclaringType); - return false; - } - }, - }; - } - - // Function to test if the file can be run as admin - private bool CanFileBeRunAsAdmin(string path) - { - string fileExtension = Path.GetExtension(path); - foreach (string extension in appExtensions) - { - // Using OrdinalIgnoreCase since this is internal - if (extension.Equals(fileExtension, StringComparison.OrdinalIgnoreCase)) - { - return true; - } - } - - return false; - } - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "We want to keep the process alive, and instead log and show an error message")] - private ContextMenuResult CreateOpenContainingFolderResult(SearchResult record) - { - return new ContextMenuResult - { - PluginName = Assembly.GetExecutingAssembly().GetName().Name, - Title = Properties.Resources.open_containing_folder, - Glyph = "\xE838", - FontFamily = "Segoe MDL2 Assets", - AcceleratorKey = Key.E, - AcceleratorModifiers = ModifierKeys.Control | ModifierKeys.Shift, - Action = _ => - { - if (!Helper.OpenInShell("explorer.exe", $"/select,\"{record.Path}\"")) - { - var message = $"{Properties.Resources.folder_open_failed} {record.Path}"; - _context.API.ShowMsg(message); - return false; - } - - return true; - }, - }; - } - } -} +// Copyright (c) Microsoft Corporation +// The Microsoft Corporation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.IO; +using System.IO.Abstractions; +using System.Reflection; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Input; +using Wox.Infrastructure; +using Wox.Plugin; +using Wox.Plugin.Logger; + +namespace Community.PowerToys.Run.Plugin.Everything +{ + internal class ContextMenuLoader : IContextMenu + { + private readonly PluginInitContext _context; + + // Extensions for adding run as admin context menu item for applications + private readonly string[] appExtensions = { ".exe", ".bat", ".appref-ms", ".lnk" }; + + public ContextMenuLoader(PluginInitContext context) + { + _context = context; + } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "We want to keep the process alive, and instead log and show an error message")] + public List LoadContextMenus(Result selectedResult) + { + var contextMenus = new List(); + if (selectedResult.ContextData is SearchResult record) + { + bool isFile = Path.HasExtension(record.Path); + + if (isFile) + { + contextMenus.Add(CreateOpenContainingFolderResult(record)); + } + + // Test to check if File can be Run as admin, if yes, we add a 'run as admin' context menu item + if (CanFileBeRunAsAdmin(record.Path)) + { + contextMenus.Add(CreateRunAsAdminContextMenu(record)); + } + + contextMenus.Add(new ContextMenuResult + { + PluginName = Assembly.GetExecutingAssembly().GetName().Name, + Title = Properties.Resources.copy_path, + Glyph = "\xE8C8", + FontFamily = "Segoe MDL2 Assets", + AcceleratorKey = Key.C, + AcceleratorModifiers = ModifierKeys.Control, + + Action = (context) => + { + try + { + Clipboard.SetText(record.Path); + return true; + } + catch (Exception e) + { + var message = Properties.Resources.clipboard_failed; + Log.Exception(message, e, GetType()); + + _context.API.ShowMsg(message); + return false; + } + }, + }); + contextMenus.Add(new ContextMenuResult + { + PluginName = Assembly.GetExecutingAssembly().GetName().Name, + Title = Properties.Resources.open_in_console, + Glyph = "\xE756", + FontFamily = "Segoe MDL2 Assets", + AcceleratorKey = Key.C, + AcceleratorModifiers = ModifierKeys.Control | ModifierKeys.Shift, + + Action = (context) => + { + try + { + if (isFile) + { + Helper.OpenInConsole(Path.GetDirectoryName(record.Path)); + } + else + { + Helper.OpenInConsole(record.Path); + } + + return true; + } + catch (Exception e) + { + Log.Exception($"Failed to open {record.Path} in console, {e.Message}", e, GetType()); + return false; + } + }, + }); + } + + return contextMenus; + } + + // Function to add the context menu item to run as admin + [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "We want to keep the process alive, and instead log the exception message")] + private static ContextMenuResult CreateRunAsAdminContextMenu(SearchResult record) + { + return new ContextMenuResult + { + PluginName = Assembly.GetExecutingAssembly().GetName().Name, + Title = Properties.Resources.run_as_admin, + Glyph = "\xE7EF", + FontFamily = "Segoe MDL2 Assets", + AcceleratorKey = Key.Enter, + AcceleratorModifiers = ModifierKeys.Control | ModifierKeys.Shift, + Action = _ => + { + try + { + Task.Run(() => Helper.RunAsAdmin(record.Path)); + return true; + } + catch (Exception e) + { + Log.Exception($"Failed to run {record.Path} as admin, {e.Message}", e, MethodBase.GetCurrentMethod().DeclaringType); + return false; + } + }, + }; + } + + // Function to test if the file can be run as admin + private bool CanFileBeRunAsAdmin(string path) + { + string fileExtension = Path.GetExtension(path); + foreach (string extension in appExtensions) + { + // Using OrdinalIgnoreCase since this is internal + if (extension.Equals(fileExtension, StringComparison.OrdinalIgnoreCase)) + { + return true; + } + } + + return false; + } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "We want to keep the process alive, and instead log and show an error message")] + private ContextMenuResult CreateOpenContainingFolderResult(SearchResult record) + { + return new ContextMenuResult + { + PluginName = Assembly.GetExecutingAssembly().GetName().Name, + Title = Properties.Resources.open_containing_folder, + Glyph = "\xE838", + FontFamily = "Segoe MDL2 Assets", + AcceleratorKey = Key.E, + AcceleratorModifiers = ModifierKeys.Control | ModifierKeys.Shift, + Action = _ => + { + if (!Helper.OpenInShell("explorer.exe", $"/select,\"{record.Path}\"")) + { + var message = $"{Properties.Resources.folder_open_failed} {record.Path}"; + _context.API.ShowMsg(message); + return false; + } + + return true; + }, + }; + } + } +} diff --git a/Main.cs b/Main.cs index fe8d21a..0cadd82 100644 --- a/Main.cs +++ b/Main.cs @@ -1,208 +1,207 @@ -// Copyright (c) Microsoft Corporation -// The Microsoft Corporation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections.Generic; -using System.Globalization; -using System.IO.Abstractions; -using System.Linq; -using System.Text; -using System.Text.RegularExpressions; -using System.Threading; -using System.Windows.Controls; -using Community.PowerToys.Run.Plugin.Everything.Properties; -using ManagedCommon; -using Microsoft.PowerToys.Settings.UI.Library; -using Wox.Infrastructure; -using Wox.Infrastructure.Storage; -using Wox.Plugin; -using Wox.Plugin.Logger; -using static Community.PowerToys.Run.Plugin.Everything.NativeMethods; - -namespace Community.PowerToys.Run.Plugin.Everything -{ - public class Main : IPlugin, IDisposable, IDelayedExecutionPlugin, IContextMenu, ISettingProvider - { - private const string Wait = nameof(Wait); - private const string Top = nameof(Top); - private const string Preview = nameof(Preview); - private readonly string reservedStringPattern = @"^[\/\\\$\%]+$|^.*[<>].*$"; - private bool _wait; - private bool _top; - private bool _preview; - - public string Name => Resources.plugin_name; - - public string Description => Resources.plugin_description; - - public IEnumerable AdditionalOptions => new List() - { - new PluginAdditionalOption() - { - Key = Top, - DisplayLabel = Resources.Top, - Value = false, - }, - new PluginAdditionalOption() - { - Key = Wait, - DisplayLabel = Resources.Wait, - Value = false, - }, - new PluginAdditionalOption() - { - Key = Preview, - DisplayLabel = Resources.Preview, - Value = false, - }, - }; - - private IContextMenu _contextMenuLoader; - private PluginInitContext _context; - private bool disposed; - private static string _warningIconPath; - - internal static string WarningIcon - { - get - { - return _warningIconPath; - } - } - - private static CancellationTokenSource source; - - public void Init(PluginInitContext context) - { - _context = context; - _contextMenuLoader = new ContextMenuLoader(context); - _context.API.ThemeChanged += OnThemeChanged; - UpdateIconPath(_context.API.GetCurrentTheme()); - EverythingSetup(); - } - - public List Query(Query query) - { - List results = new List(); - return results; - } - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "We want to keep the process alive but will log the exception")] - [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1062:Validate arguments of public methods", Justification = "Already validated")] - public List Query(Query query, bool isFullQuery) - { - List results = new List(); - if (!string.IsNullOrEmpty(query.Search)) - { - var searchQuery = query.Search; - - var regexMatch = Regex.Match(searchQuery, reservedStringPattern); - - if (!regexMatch.Success) - { - source?.Cancel(); - source = new CancellationTokenSource(); - CancellationToken token = source.Token; - source.CancelAfter(_wait ? 1000 : 120); - try - { - results.AddRange(EverythingSearch(searchQuery, _top, _preview, token)); - } - catch (OperationCanceledException) - { - results.Add(new Result() - { - Title = Resources.timeout, - SubTitle = Resources.enable_wait, - IcoPath = _warningIconPath, - Score = int.MaxValue, - }); - } - catch (System.ComponentModel.Win32Exception) - { - results.Add(new Result() - { - Title = Resources.Everything_not_running, - SubTitle = Resources.Everything_ini, - IcoPath = _warningIconPath, - QueryTextDisplay = '.' + Resources.plugin_name, - Score = int.MaxValue, - }); - } - catch (Exception e) - { - source.Dispose(); - Log.Exception("Everything Exception", e, GetType()); - } - } - } - - return results; - } - - private void OnThemeChanged(Theme oldtheme, Theme newTheme) - { - UpdateIconPath(newTheme); - } - - private static void UpdateIconPath(Theme theme) - { - if (theme == Theme.Light || theme == Theme.HighContrastWhite) - { - _warningIconPath = "Images/Warning.light.png"; - } - else - { - _warningIconPath = "Images/Warning.dark.png"; - } - } - - public List LoadContextMenus(Result selectedResult) - { - return _contextMenuLoader.LoadContextMenus(selectedResult); - } - - public Control CreateSettingPanel() - { - throw new NotImplementedException(); - } - - public void UpdateSettings(PowerLauncherPluginSettings settings) - { - var wait = false; - var top = false; - var nopreview = false; - if (settings != null && settings.AdditionalOptions != null) - { - wait = settings.AdditionalOptions.FirstOrDefault(x => x.Key == Wait)?.Value ?? false; - top = settings.AdditionalOptions.FirstOrDefault(x => x.Key == Top)?.Value ?? false; - nopreview = settings.AdditionalOptions.FirstOrDefault(x => x.Key == Preview)?.Value ?? false; - } - - _top = top; - _wait = wait; - _preview = nopreview; - } - - protected virtual void Dispose(bool disposing) - { - if (!disposed) - { - if (disposing) - { - source.Dispose(); - } - - disposed = true; - } - } - - public void Dispose() - { - // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method - Dispose(disposing: true); - GC.SuppressFinalize(this); - } - } -} +// Copyright (c) Microsoft Corporation +// The Microsoft Corporation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO.Abstractions; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading; +using System.Windows.Controls; +using Community.PowerToys.Run.Plugin.Everything.Properties; +using ManagedCommon; +using Microsoft.PowerToys.Settings.UI.Library; +using Wox.Infrastructure; +using Wox.Infrastructure.Storage; +using Wox.Plugin; +using Wox.Plugin.Logger; +using static Community.PowerToys.Run.Plugin.Everything.NativeMethods; + +namespace Community.PowerToys.Run.Plugin.Everything +{ + public class Main : IPlugin, IDisposable, IDelayedExecutionPlugin, IContextMenu, ISettingProvider + { + private const string Wait = nameof(Wait); + private const string Top = nameof(Top); + private const string NoPreview = nameof(NoPreview); + private readonly string reservedStringPattern = @"^[\/\\\$\%]+$|^.*[<>].*$"; + private bool _wait; + private bool _top; + private bool _preview; + + public string Name => Resources.plugin_name; + + public string Description => Resources.plugin_description; + + public IEnumerable AdditionalOptions => new List() + { + new PluginAdditionalOption() + { + Key = Top, + DisplayLabel = Resources.Top, + Value = false, + }, + new PluginAdditionalOption() + { + Key = Wait, + DisplayLabel = Resources.Wait, + Value = false, + }, + new PluginAdditionalOption() + { + Key = NoPreview, + DisplayLabel = Resources.Preview, + Value = false, + }, + }; + + private IContextMenu _contextMenuLoader; + private PluginInitContext _context; + private bool disposed; + private static string _warningIconPath; + + internal static string WarningIcon + { + get + { + return _warningIconPath; + } + } + + private static CancellationTokenSource source; + + public void Init(PluginInitContext context) + { + _context = context; + _contextMenuLoader = new ContextMenuLoader(context); + _context.API.ThemeChanged += OnThemeChanged; + UpdateIconPath(_context.API.GetCurrentTheme()); + EverythingSetup(); + } + + public List Query(Query query) + { + List results = new List(); + return results; + } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "We want to keep the process alive but will log the exception")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1062:Validate arguments of public methods", Justification = "Already validated")] + public List Query(Query query, bool isFullQuery) + { + List results = new List(); + if (!string.IsNullOrEmpty(query.Search)) + { + var searchQuery = query.Search; + + var regexMatch = Regex.Match(searchQuery, reservedStringPattern); + + if (!regexMatch.Success) + { + source?.Cancel(); + source = new CancellationTokenSource(); + CancellationToken token = source.Token; + source.CancelAfter(_wait ? 1000 : 150); + try + { + results.AddRange(EverythingSearch(searchQuery, _top, _preview, token)); + } + catch (OperationCanceledException) + { + results.Add(new Result() + { + Title = Resources.timeout, + SubTitle = Resources.enable_wait, + IcoPath = _warningIconPath, + Score = int.MaxValue, + }); + } + catch (System.ComponentModel.Win32Exception) + { + results.Add(new Result() + { + Title = Resources.Everything_not_running, + SubTitle = Resources.Everything_ini, + IcoPath = _warningIconPath, + QueryTextDisplay = '.' + Resources.plugin_name, + Score = int.MaxValue, + }); + } + catch (Exception e) + { + source.Cancel(); + Log.Exception("Everything Exception", e, GetType()); + } + } + } + + return results; + } + + private void OnThemeChanged(Theme oldtheme, Theme newTheme) + { + UpdateIconPath(newTheme); + } + + private static void UpdateIconPath(Theme theme) + { + if (theme == Theme.Light || theme == Theme.HighContrastWhite) + { + _warningIconPath = "Images/Warning.light.png"; + } + else + { + _warningIconPath = "Images/Warning.dark.png"; + } + } + + public List LoadContextMenus(Result selectedResult) + { + return _contextMenuLoader.LoadContextMenus(selectedResult); + } + + public Control CreateSettingPanel() + { + throw new NotImplementedException(); + } + + public void UpdateSettings(PowerLauncherPluginSettings settings) + { + var wait = false; + var top = false; + var nopreview = false; + if (settings != null && settings.AdditionalOptions != null) + { + wait = settings.AdditionalOptions.FirstOrDefault(x => x.Key == Wait)?.Value ?? false; + top = settings.AdditionalOptions.FirstOrDefault(x => x.Key == Top)?.Value ?? false; + nopreview = settings.AdditionalOptions.FirstOrDefault(x => x.Key == NoPreview)?.Value ?? false; + } + + _top = top; + _wait = wait; + _preview = nopreview; + } + + protected virtual void Dispose(bool disposing) + { + if (!disposed) + { + if (disposing) + { + } + + disposed = true; + } + } + + public void Dispose() + { + // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method + Dispose(disposing: true); + GC.SuppressFinalize(this); + } + } +} diff --git a/NativeMethods.cs b/NativeMethods.cs index 56afcc4..e2d0c2b 100644 --- a/NativeMethods.cs +++ b/NativeMethods.cs @@ -1,228 +1,237 @@ -// Copyright (c) Microsoft Corporation -// The Microsoft Corporation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections; -using System.Collections.Generic; -using System.ComponentModel; -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -using System.IO; -using System.IO.Abstractions; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using Community.PowerToys.Run.Plugin.Everything.Properties; -using Microsoft.Win32; -using Wox.Plugin; - -namespace Community.PowerToys.Run.Plugin.Everything -{ - internal static class NativeMethods - { - internal enum Request - { - FILE_NAME = 0x00000001, - PATH = 0x00000002, - FULL_PATH_AND_FILE_NAME = 0x00000004, - EXTENSION = 0x00000008, - SIZE = 0x00000010, - DATE_CREATED = 0x00000020, - DATE_MODIFIED = 0x00000040, - DATE_ACCESSED = 0x00000080, - ATTRIBUTES = 0x00000100, - FILE_LIST_FILE_NAME = 0x00000200, - RUN_COUNT = 0x00000400, - DATE_RUN = 0x00000800, - DATE_RECENTLY_CHANGED = 0x00001000, - HIGHLIGHTED_FILE_NAME = 0x00002000, - HIGHLIGHTED_PATH = 0x00004000, - HIGHLIGHTED_FULL_PATH_AND_FILE_NAME = 0x00008000, - } - - internal enum Sort - { - NAME_ASCENDING = 1, - NAME_DESCENDING, - PATH_ASCENDING, - PATH_DESCENDING, - SIZE_ASCENDING, - SIZE_DESCENDING, - EXTENSION_ASCENDING, - EXTENSION_DESCENDING, - TYPE_NAME_ASCENDING, - TYPE_NAME_DESCENDING, - DATE_CREATED_ASCENDING, - DATE_CREATED_DESCENDING, - DATE_MODIFIED_ASCENDING, - DATE_MODIFIED_DESCENDING, - ATTRIBUTES_ASCENDING, - ATTRIBUTES_DESCENDING, - FILE_LIST_FILENAME_ASCENDING, - FILE_LIST_FILENAME_DESCENDING, - RUN_COUNT_ASCENDING, - RUN_COUNT_DESCENDING, - DATE_RECENTLY_CHANGED_ASCENDING, - DATE_RECENTLY_CHANGED_DESCENDING, - DATE_ACCESSED_ASCENDING, - DATE_ACCESSED_DESCENDING, - DATE_RUN_ASCENDING, - DATE_RUN_DESCENDING, - } - - internal const string dllName = "Everything64.dll"; // Included dll is a modified file without locking, if this creates issues, replace with official dll - -#pragma warning disable SA1516 // Elements should be separated by blank line - [DllImport(dllName)] - public static extern uint Everything_GetNumResults(); - [DllImport(dllName, CharSet = CharSet.Unicode)] - public static extern void Everything_GetResultFullPathName(uint nIndex, StringBuilder lpString, uint nMaxCount); - [DllImport(dllName)] - public static extern bool Everything_QueryW(bool bWait); - [DllImport(dllName)] - public static extern void Everything_SetMax(uint dwMax); - [DllImport(dllName)] - public static extern void Everything_SetRequestFlags(Request RequestFlags); - [DllImport(dllName, CharSet = CharSet.Unicode)] - public static extern uint Everything_SetSearchW(string lpSearchString); - [DllImport(dllName)] - public static extern void Everything_SetSort(Sort SortType); - - private const int max = 20; -#pragma warning disable SA1503 // Braces should not be omitted - public static void EverythingSetup() - { - Everything_SetRequestFlags(Request.FULL_PATH_AND_FILE_NAME); - Everything_SetSort(Sort.DATE_MODIFIED_DESCENDING); - Everything_SetMax(max); - } - - public static IEnumerable EverythingSearch(string qry, bool top, bool preview, CancellationToken token) - { - _ = Everything_SetSearchW(qry); - if (token.IsCancellationRequested) token.ThrowIfCancellationRequested(); - if (!Everything_QueryW(true)) - { - throw new Win32Exception("Unable to Query"); - } - - uint resultCount = Everything_GetNumResults(); - - for (uint i = 0; i < resultCount; i++) - { - if (token.IsCancellationRequested) break; - StringBuilder sb = new StringBuilder(260); - Everything_GetResultFullPathName(i, sb, 260); - string fullPath = sb.ToString(); - string name = Path.GetFileName(fullPath); - string path; - bool isFolder = Path.HasExtension(fullPath); - if (isFolder) - path = fullPath; - else - path = Path.GetDirectoryName(fullPath); - string ext = Path.GetExtension(fullPath); - - var r = new Result() - { - Title = name, - ToolTipData = new ToolTipData("Name : " + name, "Path : " + path), - SubTitle = Resources.plugin_name + ": " + fullPath, - IcoPath = (preview || string.IsNullOrEmpty(ext) || string.IsNullOrEmpty((string)Icons[ext])) ? fullPath : (string)Icons[ext], - ContextData = new SearchResult() - { - Path = fullPath, - Title = name, - }, - Action = e => - { - using (var process = new Process()) - { - process.StartInfo.FileName = fullPath; - process.StartInfo.WorkingDirectory = path; - process.StartInfo.UseShellExecute = true; - - try - { - process.Start(); - return true; - } - catch (Win32Exception) - { - return false; - } - } - }, - QueryTextDisplay = isFolder ? path : name, - }; - if (top) r.Score = (int)(300 - i); - yield return r; - } - - if (token.IsCancellationRequested) - { - yield return new Result() - { - Title = Resources.timeout, - SubTitle = Resources.enable_wait, - IcoPath = Main.WarningIcon, - Score = int.MaxValue, - }; - } - } - - // Credits https://www.codeproject.com/Articles/29137/Get-Registered-File-Types-and-Their-Associated-Ico - [DllImport("shell32.dll", EntryPoint = "ExtractIconA", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)] - private static extern IntPtr ExtractIcon(int hInst, string lpszExeFileName, int nIconIndex); - internal static readonly Hashtable Icons = GetFileTypeAndIcon(); - internal static Hashtable GetFileTypeAndIcon() - { - try - { - RegistryKey rkRoot = Registry.ClassesRoot; - string[] keyNames = rkRoot.GetSubKeyNames(); - Hashtable iconsInfo = new Hashtable(StringComparer.InvariantCultureIgnoreCase); - foreach (string keyName in keyNames) - { - if (string.IsNullOrEmpty(keyName)) - continue; - int indexOfPoint = keyName.IndexOf(".", StringComparison.CurrentCulture); - if (indexOfPoint != 0) - continue; - RegistryKey rkFileType = rkRoot.OpenSubKey(keyName); - if (rkFileType == null) - continue; - object defaultValue = rkFileType.GetValue(string.Empty); - if (defaultValue == null) - continue; - string defaultIcon = defaultValue.ToString() + "\\DefaultIcon"; - RegistryKey rkFileIcon = rkRoot.OpenSubKey(defaultIcon); - if (rkFileIcon != null) - { - object value = rkFileIcon.GetValue(string.Empty); - if (value != null) - { - string fileParam = value.ToString().Replace("\"", string.Empty, StringComparison.CurrentCulture).Split(',')[0].Trim(); - iconsInfo.Add(keyName, fileParam); - } - - rkFileIcon.Close(); - } - - rkFileType.Close(); - } - - rkRoot.Close(); - return iconsInfo; - } - catch (Exception) - { - throw; - } - } -#pragma warning restore SA1503 // Braces should not be omitted - } -} +// Copyright (c) Microsoft Corporation +// The Microsoft Corporation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections; +using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; +using System.IO; +using System.IO.Abstractions; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Community.PowerToys.Run.Plugin.Everything.Properties; +using Microsoft.Win32; +using Wox.Plugin; + +namespace Community.PowerToys.Run.Plugin.Everything +{ + internal static class NativeMethods + { + [Flags] + internal enum Request + { + FILE_NAME = 0x00000001, + PATH = 0x00000002, + FULL_PATH_AND_FILE_NAME = 0x00000004, + EXTENSION = 0x00000008, + SIZE = 0x00000010, + DATE_CREATED = 0x00000020, + DATE_MODIFIED = 0x00000040, + DATE_ACCESSED = 0x00000080, + ATTRIBUTES = 0x00000100, + FILE_LIST_FILE_NAME = 0x00000200, + RUN_COUNT = 0x00000400, + DATE_RUN = 0x00000800, + DATE_RECENTLY_CHANGED = 0x00001000, + HIGHLIGHTED_FILE_NAME = 0x00002000, + HIGHLIGHTED_PATH = 0x00004000, + HIGHLIGHTED_FULL_PATH_AND_FILE_NAME = 0x00008000, + } + + internal enum Sort + { + NAME_ASCENDING = 1, + NAME_DESCENDING, + PATH_ASCENDING, + PATH_DESCENDING, + SIZE_ASCENDING, + SIZE_DESCENDING, + EXTENSION_ASCENDING, + EXTENSION_DESCENDING, + TYPE_NAME_ASCENDING, + TYPE_NAME_DESCENDING, + DATE_CREATED_ASCENDING, + DATE_CREATED_DESCENDING, + DATE_MODIFIED_ASCENDING, + DATE_MODIFIED_DESCENDING, + ATTRIBUTES_ASCENDING, + ATTRIBUTES_DESCENDING, + FILE_LIST_FILENAME_ASCENDING, + FILE_LIST_FILENAME_DESCENDING, + RUN_COUNT_ASCENDING, + RUN_COUNT_DESCENDING, + DATE_RECENTLY_CHANGED_ASCENDING, + DATE_RECENTLY_CHANGED_DESCENDING, + DATE_ACCESSED_ASCENDING, + DATE_ACCESSED_DESCENDING, + DATE_RUN_ASCENDING, + DATE_RUN_DESCENDING, + } + + [StructLayout(LayoutKind.Sequential)] + internal struct SHFILEINFO + { + internal IntPtr hIcon; + internal int iIcon; + internal int dwAttributes; + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)] + internal string szDisplayName; + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 80)] + internal string szTypeName; + } + + internal const string dllName = "Everything64.dll"; // Included dll is a modified file without locking, if this creates issues, replace with official dll + +#pragma warning disable SA1516 // Elements should be separated by blank line + [DllImport(dllName)] + public static extern uint Everything_GetNumResults(); + [DllImport(dllName, CharSet = CharSet.Unicode)] + public static extern void Everything_GetResultFullPathName(uint nIndex, StringBuilder lpString, uint nMaxCount); + [DllImport(dllName)] + public static extern bool Everything_QueryW(bool bWait); + [DllImport(dllName)] + public static extern void Everything_SetMax(uint dwMax); + [DllImport(dllName)] + public static extern void Everything_SetRequestFlags(Request RequestFlags); + [DllImport(dllName, CharSet = CharSet.Unicode)] + public static extern uint Everything_SetSearchW(string lpSearchString); + [DllImport(dllName)] + public static extern void Everything_SetSort(Sort SortType); + + private const int max = 20; +#pragma warning disable SA1503 // Braces should not be omitted + public static void EverythingSetup() + { + Everything_SetRequestFlags(Request.FULL_PATH_AND_FILE_NAME); + Everything_SetSort(Sort.DATE_MODIFIED_DESCENDING); + Everything_SetMax(max); + } + + public static IEnumerable EverythingSearch(string qry, bool top, bool preview, CancellationToken token) + { + _ = Everything_SetSearchW(qry); + if (token.IsCancellationRequested) token.ThrowIfCancellationRequested(); + if (!Everything_QueryW(true)) + { + throw new Win32Exception("Unable to Query"); + } + + uint resultCount = Everything_GetNumResults(); + + for (uint i = 0; i < resultCount; i++) + { + if (token.IsCancellationRequested) break; + StringBuilder sb = new StringBuilder(260); + Everything_GetResultFullPathName(i, sb, 260); + string fullPath = sb.ToString(); + string name = Path.GetFileName(fullPath); + string path; + bool isFolder = Path.HasExtension(fullPath); + if (isFolder) + path = fullPath; + else + path = Path.GetDirectoryName(fullPath); + string ext = Path.GetExtension(fullPath); + + var r = new Result() + { + Title = name, + ToolTipData = new ToolTipData("Name : " + name, "Path : " + path), + SubTitle = Resources.plugin_name + ": " + fullPath, + IcoPath = (preview || string.IsNullOrEmpty(ext)) ? fullPath : (string)Icons[ext], + ContextData = new SearchResult() + { + Path = fullPath, + Title = name, + }, + Action = e => + { + using (var process = new Process()) + { + process.StartInfo.FileName = fullPath; + process.StartInfo.WorkingDirectory = path; + process.StartInfo.UseShellExecute = true; + + try + { + process.Start(); + return true; + } + catch (Win32Exception) + { + return false; + } + } + }, + QueryTextDisplay = isFolder ? path : name, + }; + if (top) r.Score = (int)(max - i); + yield return r; + } + + if (token.IsCancellationRequested) + { + yield return new Result() + { + Title = Resources.timeout, + SubTitle = Resources.enable_wait, + IcoPath = Main.WarningIcon, + Score = int.MaxValue, + }; + } + } + + internal static readonly Hashtable Icons = GetFileTypeAndIcon(); + internal static Hashtable GetFileTypeAndIcon() + { + try + { + RegistryKey rkRoot = Registry.ClassesRoot; + string[] keyNames = rkRoot.GetSubKeyNames(); + Hashtable iconsInfo = new Hashtable(StringComparer.InvariantCultureIgnoreCase); + foreach (string keyName in keyNames) + { + if (string.IsNullOrEmpty(keyName)) + continue; + int indexOfPoint = keyName.IndexOf(".", StringComparison.CurrentCulture); + if (indexOfPoint != 0) + continue; + RegistryKey rkFileType = rkRoot.OpenSubKey(keyName); + if (rkFileType == null) + continue; + object defaultValue = rkFileType.GetValue(string.Empty); + if (defaultValue == null) + continue; + string prog = defaultValue.ToString() + "\\shell\\Open\\command"; + RegistryKey rkFileIcon = rkRoot.OpenSubKey(prog); + if (rkFileIcon != null) + { + object value = rkFileIcon.GetValue(string.Empty); + if (value != null) + { + string fileParam = value.ToString().Split("\" ")[0].Replace("\"", string.Empty, StringComparison.CurrentCulture).Trim(); + iconsInfo.Add(keyName, fileParam); + } + + rkFileIcon.Close(); + } + + rkFileType.Close(); + } + + rkRoot.Close(); + return iconsInfo; + } + catch (Exception) + { + throw; + } + } +#pragma warning restore SA1503 // Braces should not be omitted + } +} diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs index 8a0d9f7..5f35077 100644 --- a/Properties/Resources.Designer.cs +++ b/Properties/Resources.Designer.cs @@ -1,198 +1,198 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Community.PowerToys.Run.Plugin.Everything.Properties { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - public class Resources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - public static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Community.PowerToys.Run.Plugin.Everything.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - public static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to Fail to set text in clipboard. - /// - public static string clipboard_failed { - get { - return ResourceManager.GetString("clipboard_failed", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Copy path (Ctrl+C). - /// - public static string copy_path { - get { - return ResourceManager.GetString("copy_path", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Enable Wait setting under PowerToys Run > Everything. - /// - public static string enable_wait { - get { - return ResourceManager.GetString("enable_wait", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Install Everything if not installed. - /// - public static string Everything_ini { - get { - return ResourceManager.GetString("Everything_ini", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Everything is not running. - /// - public static string Everything_not_running { - get { - return ResourceManager.GetString("Everything_not_running", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Fail to open folder at. - /// - public static string folder_open_failed { - get { - return ResourceManager.GetString("folder_open_failed", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Open containing folder (Ctrl+Shift+E). - /// - public static string open_containing_folder { - get { - return ResourceManager.GetString("open_containing_folder", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Open path in console (Ctrl+Shift+C). - /// - public static string open_in_console { - get { - return ResourceManager.GetString("open_in_console", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Get search results from Everything. - /// - public static string plugin_description { - get { - return ResourceManager.GetString("plugin_description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Everything. - /// - public static string plugin_name { - get { - return ResourceManager.GetString("plugin_name", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Preview - Preview file content as icon, may cause freezing if file not local.. - /// - public static string Preview { - get { - return ResourceManager.GetString("Preview", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Run as administrator (Ctrl+Shift+Enter). - /// - public static string run_as_admin { - get { - return ResourceManager.GetString("run_as_admin", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Timed out before finishing the query. - /// - public static string timeout { - get { - return ResourceManager.GetString("timeout", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Top - Insert result at the top of the list, may cause pre-selection issue.. - /// - public static string Top { - get { - return ResourceManager.GetString("Top", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Wait - Wait longer for the query to finish, enable only if prompted to.. - /// - public static string Wait { - get { - return ResourceManager.GetString("Wait", resourceCulture); - } - } - } -} +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Community.PowerToys.Run.Plugin.Everything.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + public class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Community.PowerToys.Run.Plugin.Everything.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to Fail to set text in clipboard. + /// + public static string clipboard_failed { + get { + return ResourceManager.GetString("clipboard_failed", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Copy path (Ctrl+C). + /// + public static string copy_path { + get { + return ResourceManager.GetString("copy_path", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Enable Wait setting under PowerToys Run > Everything. + /// + public static string enable_wait { + get { + return ResourceManager.GetString("enable_wait", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Install Everything if not installed. + /// + public static string Everything_ini { + get { + return ResourceManager.GetString("Everything_ini", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Everything is not running. + /// + public static string Everything_not_running { + get { + return ResourceManager.GetString("Everything_not_running", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Fail to open folder at. + /// + public static string folder_open_failed { + get { + return ResourceManager.GetString("folder_open_failed", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Open containing folder (Ctrl+Shift+E). + /// + public static string open_containing_folder { + get { + return ResourceManager.GetString("open_containing_folder", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Open path in console (Ctrl+Shift+C). + /// + public static string open_in_console { + get { + return ResourceManager.GetString("open_in_console", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Get search results from Everything. + /// + public static string plugin_description { + get { + return ResourceManager.GetString("plugin_description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Everything. + /// + public static string plugin_name { + get { + return ResourceManager.GetString("plugin_name", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Preview - Preview file content as icon, may cause freezing if file is not local.. + /// + public static string Preview { + get { + return ResourceManager.GetString("Preview", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Run as administrator (Ctrl+Shift+Enter). + /// + public static string run_as_admin { + get { + return ResourceManager.GetString("run_as_admin", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Timed out before finishing the query. + /// + public static string timeout { + get { + return ResourceManager.GetString("timeout", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Top - Insert result at the top of the list, may cause pre-selectino issue.. + /// + public static string Top { + get { + return ResourceManager.GetString("Top", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Wait - Wait longer for the query to finish, enable only if prompted to.. + /// + public static string Wait { + get { + return ResourceManager.GetString("Wait", resourceCulture); + } + } + } +} diff --git a/Properties/Resources.resx b/Properties/Resources.resx index 2d7da90..af19dd2 100644 --- a/Properties/Resources.resx +++ b/Properties/Resources.resx @@ -1,165 +1,165 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Fail to set text in clipboard - - - Copy path (Ctrl+C) - - - Enable Wait setting under PowerToys Run > Everything - - - Install Everything if not installed - - - Everything is not running - - - Fail to open folder at - - - Open containing folder (Ctrl+Shift+E) - - - Open path in console (Ctrl+Shift+C) - - - Get search results from Everything - - - Everything - - - Preview - Preview file content as icon, may cause freezing if file not local. - - - Run as administrator (Ctrl+Shift+Enter) - - - Timed out before finishing the query - - - Top - Insert result at the top of the list, may cause pre-selection issue. - - - Wait - Wait longer for the query to finish, enable only if prompted to. - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Fail to set text in clipboard + + + Copy path (Ctrl+C) + + + Enable Wait setting under PowerToys Run > Everything + + + Install Everything if not installed + + + Everything is not running + + + Fail to open folder at + + + Open containing folder (Ctrl+Shift+E) + + + Open path in console (Ctrl+Shift+C) + + + Get search results from Everything + + + Everything + + + Preview - Preview file content as icon, may cause freezing if file is not local. + + + Run as administrator (Ctrl+Shift+Enter) + + + Timed out before finishing the query + + + Top - Insert result at the top of the list, may cause pre-selectino issue. + + + Wait - Wait longer for the query to finish, enable only if prompted to. + \ No newline at end of file diff --git a/README.md b/README.md index 58d944f..e365967 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ -# Everything for PowerToys Run ---- -This repo is to be used as a submodule for [PowerToys repo](https://github.com/lin-ycv/PowerToys/tree/Everything), this will not compile when used standalone, as it's missing references from PowerToys. - -The release is the compiled reult of this repo, extract the downloaded folder to `C:\Program Files\PowerToys\modules\launcher\Plugins` - -[Everything](https://www.voidtools.com/downloads/) has to be downloaded seperately, and be running in order for this pluging to work.
-**\*This does not work with the lite version of Everything, it does not support IPC**
-*if you are on 1.5 alpha, you need to [Disable 1.5a Instance](http://www.voidtools.com/forum/viewtopic.php?f=12&t=9799#instance)* +# Everything for PowerToys Run +--- +This repo is to be used as a submodule for [PowerToys repo](https://github.com/lin-ycv/PowerToys/tree/Everything), this will not compile when used standalone, as it's missing references from PowerToys. + +The release is the compiled result of this repo, extract the downloaded folder to `C:\Program Files\PowerToys\modules\launcher\Plugins` + +[Everything](https://www.voidtools.com/downloads/) has to be downloaded seperately, and be running in order for this pluging to work.
+**\*This does not work with the lite version of Everything, it does not support IPC**
+*if you are on 1.5 alpha, you need to [Disable 1.5a Instance](http://www.voidtools.com/forum/viewtopic.php?f=12&t=9799#instance)* \ No newline at end of file diff --git a/SearchHelper/SearchResult.cs b/SearchHelper/SearchResult.cs index a935e0e..475903e 100644 --- a/SearchHelper/SearchResult.cs +++ b/SearchHelper/SearchResult.cs @@ -1,15 +1,15 @@ -// Copyright (c) Microsoft Corporation -// The Microsoft Corporation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Community.PowerToys.Run.Plugin.Everything -{ - public class SearchResult - { - // Contains the Path of the file or folder - public string Path { get; set; } - - // Contains the Title of the file or folder - public string Title { get; set; } - } -} +// Copyright (c) Microsoft Corporation +// The Microsoft Corporation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Community.PowerToys.Run.Plugin.Everything +{ + public class SearchResult + { + // Contains the Path of the file or folder + public string Path { get; set; } + + // Contains the Title of the file or folder + public string Title { get; set; } + } +} diff --git a/plugin.json b/plugin.json index f0df61d..25c6e01 100644 --- a/plugin.json +++ b/plugin.json @@ -1,13 +1,13 @@ -{ - "ID": "A86867E2D932459CBD77D176373DD657", - "ActionKeyword": "@", - "IsGlobal": true, - "Name": "Everything", - "Author": "Yu Chieh (Victor) Lin", - "Version": "0.55.1.0", - "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" +{ + "ID": "A86867E2D932459CBD77D176373DD657", + "ActionKeyword": "@", + "IsGlobal": true, + "Name": "Everything", + "Author": "Yu Chieh (Victor) Lin", + "Version": "0.56.2.0", + "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" } \ No newline at end of file