diff --git a/.github/README.md b/.github/README.md index 25b690a..35f034b 100644 --- a/.github/README.md +++ b/.github/README.md @@ -16,8 +16,7 @@ Dev instructions are in the wiki. There are 4 different methods of installation, chose the one you prefer: 1) WinGet : `winget install lin-ycv.EverythingPowerToys` 2) Chocolatey : `choco install everythingpowertoys` -3) ~Scoop : `scoop install everythingpowertoys`~ -4) Self-Extraction Installer (EXE) : [Download from release page](https://github.com/lin-ycv/EverythingPowerToys/releases/latest) +3) Self-Extraction Installer (EXE) : [Download from release page](https://github.com/lin-ycv/EverythingPowerToys/releases/latest) 5) Manual Installation (ZIP) : [Download from release page](https://github.com/lin-ycv/EverythingPowerToys/releases/latest) Detailed explanations and instructions are on the [release page](https://github.com/lin-ycv/EverythingPowerToys/releases/latest) diff --git a/Community.PowerToys.Run.Plugin.Everything.csproj b/Community.PowerToys.Run.Plugin.Everything.csproj index 4aa90f4..2463b76 100644 --- a/Community.PowerToys.Run.Plugin.Everything.csproj +++ b/Community.PowerToys.Run.Plugin.Everything.csproj @@ -2,59 +2,34 @@ - net8.0-windows7.0 + net8.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 - Yu Chieh (Victor) Lin - https://github.com/lin-ycv/EverythingPowerToys - README.md - Everything.light.png - True - $(NoWarn),1573,1591,1712 - AnyCPU + true lin-ycv Copyright (C) lin-ycv - https://github.com/lin-ycv/EverythingPowerToys - PowerToys;Everything;EverythingPowerToys; + True + enable true - ..\..\..\..\..\$(Platform)\$(Configuration)\RunPlugins\Everything\ DEBUG;TRACE full false - ..\..\..\..\..\$(Platform)\$(Configuration)\RunPlugins\Everything\ - TRACE + TRACE true none - - False - - - - False - - - - False - - - - False - - @@ -149,8 +124,22 @@ + + + True + + + + + + + + + + + - + diff --git a/ContextMenuLoader.cs b/ContextMenuLoader.cs index a4d2f23..bc8d1fc 100644 --- a/ContextMenuLoader.cs +++ b/ContextMenuLoader.cs @@ -1,13 +1,5 @@ -using System; -using System.Collections.Generic; -using System.IO; -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 { @@ -43,7 +35,7 @@ namespace Community.PowerToys.Run.Plugin.Everything contextMenus.Add(new ContextMenuResult { PluginName = Assembly.GetExecutingAssembly().GetName().Name, - Title = Properties.Resources.open_containing_folder, + Title = Resources.open_containing_folder, Glyph = "\xE838", FontFamily = "Segoe MDL2 Assets", AcceleratorKey = Key.E, @@ -52,7 +44,7 @@ namespace Community.PowerToys.Run.Plugin.Everything { if (!Helper.OpenInShell("explorer.exe", $"/select,\"{record.Path}\"")) { - var message = $"{Properties.Resources.folder_open_failed} {Path.GetDirectoryName(record.Path)}"; + var message = $"{Resources.folder_open_failed} {Path.GetDirectoryName(record.Path)}"; _context.API.ShowMsg(message); return false; } @@ -70,7 +62,7 @@ namespace Community.PowerToys.Run.Plugin.Everything contextMenus.Add(new ContextMenuResult { PluginName = Assembly.GetExecutingAssembly().GetName().Name, - Title = Properties.Resources.run_as_admin, + Title = Resources.run_as_admin, Glyph = "\xE7EF", FontFamily = "Segoe MDL2 Assets", AcceleratorKey = Key.Enter, @@ -99,7 +91,7 @@ namespace Community.PowerToys.Run.Plugin.Everything contextMenus.Add(new ContextMenuResult { PluginName = Assembly.GetExecutingAssembly().GetName().Name, - Title = Properties.Resources.run_as_user, + Title = Resources.run_as_user, Glyph = "\xE7EE", FontFamily = "Segoe MDL2 Assets", AcceleratorKey = Key.U, @@ -126,7 +118,7 @@ namespace Community.PowerToys.Run.Plugin.Everything contextMenus.Add(new ContextMenuResult { PluginName = Assembly.GetExecutingAssembly().GetName().Name, - Title = Properties.Resources.copy_file + (_swapCopy ? Properties.Resources.copy_shortcut : Properties.Resources.copy_shortcutAlt), + Title = Resources.copy_file + (_swapCopy ? Resources.copy_shortcut : Resources.copy_shortcutAlt), Glyph = "\xE8C8", FontFamily = "Segoe MDL2 Assets", AcceleratorKey = Key.C, @@ -141,7 +133,7 @@ namespace Community.PowerToys.Run.Plugin.Everything } catch (Exception e) { - var message = Properties.Resources.clipboard_failed; + var message = Resources.clipboard_failed; Log.Exception(message, e, GetType()); _context.API.ShowMsg(message); @@ -155,7 +147,7 @@ namespace Community.PowerToys.Run.Plugin.Everything contextMenus.Add(new ContextMenuResult { PluginName = Assembly.GetExecutingAssembly().GetName().Name, - Title = Properties.Resources.copy_path + (_swapCopy ? Properties.Resources.copy_shortcutAlt : Properties.Resources.copy_shortcut), + Title = Resources.copy_path + (_swapCopy ? Resources.copy_shortcutAlt : Resources.copy_shortcut), Glyph = "\xE71B", FontFamily = "Segoe MDL2 Assets", AcceleratorKey = Key.C, @@ -170,7 +162,7 @@ namespace Community.PowerToys.Run.Plugin.Everything } catch (Exception e) { - var message = Properties.Resources.clipboard_failed; + var message = Resources.clipboard_failed; Log.Exception(message, e, GetType()); _context.API.ShowMsg(message); @@ -184,7 +176,7 @@ namespace Community.PowerToys.Run.Plugin.Everything contextMenus.Add(new ContextMenuResult { PluginName = Assembly.GetExecutingAssembly().GetName().Name, - Title = Properties.Resources.open_in_console, + Title = Resources.open_in_console, Glyph = "\xE756", FontFamily = "Segoe MDL2 Assets", AcceleratorKey = Key.C, diff --git a/Everything.cs b/Everything.cs index d041cef..53a1c9c 100644 --- a/Everything.cs +++ b/Everything.cs @@ -1,12 +1,4 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Diagnostics; -using System.IO; -using System.Text; -using Community.PowerToys.Run.Plugin.Everything.Properties; -using Wox.Plugin; -using static Community.PowerToys.Run.Plugin.Everything.Interop.NativeMethods; +using System.ComponentModel; namespace Community.PowerToys.Run.Plugin.Everything { @@ -14,8 +6,8 @@ namespace Community.PowerToys.Run.Plugin.Everything { internal Everything(Settings setting) { - Everything_SetRequestFlags(Request.FULL_PATH_AND_FILE_NAME); - UpdateSettings(setting); + Everything_SetRequestFlags(Request.FULL_PATH_AND_FILE_NAME); + UpdateSettings(setting); } internal void UpdateSettings(Settings setting) @@ -57,7 +49,7 @@ namespace Community.PowerToys.Run.Plugin.Everything } } - _ = Everything_SetSearchW(query); + Everything_SetSearchW(query); if (!Everything_QueryW(true)) { throw new Win32Exception("Unable to Query"); @@ -72,9 +64,9 @@ namespace Community.PowerToys.Run.Plugin.Everything for (uint i = 0; i < resultCount; i++) { - StringBuilder buffer = new(260); - Everything_GetResultFullPathName(i, buffer, 260); - string fullPath = buffer.ToString(); + char[] buffer = new char[260]; + uint length = Everything_GetResultFullPathName(i, buffer, (uint)buffer.Length); + string fullPath = new(buffer, 0, (int)length); string name = Path.GetFileName(fullPath); bool isFolder = Everything_IsFolderResult(i); string path = isFolder ? fullPath : Path.GetDirectoryName(fullPath); @@ -87,7 +79,7 @@ namespace Community.PowerToys.Run.Plugin.Everything SubTitle = Resources.plugin_name + ": " + fullPath, IcoPath = isFolder ? "Images/folder.png" : (setting.Preview ? - fullPath : (SearchHelper.IconLoader.Icon(ext) ?? "Images/file.png")), + fullPath : "Images/file.png"), ContextData = new SearchResult() { Path = fullPath, diff --git a/EverythingARM64.dll b/EverythingARM64.dll new file mode 100644 index 0000000..49f487d Binary files /dev/null and b/EverythingARM64.dll differ diff --git a/GlobalSuppressions.cs b/GlobalSuppressions.cs index 056e223..85d842b 100644 --- a/GlobalSuppressions.cs +++ b/GlobalSuppressions.cs @@ -12,5 +12,4 @@ using System.Diagnostics.CodeAnalysis; [assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1602:Enumeration items should be documented", Justification = "Reviewed")] [assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1633:File should have header", Justification = "Reviewed")] [assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1636:FileHeaderCopyrightTextMustMatch", Justification = "Reviewed.")] -[assembly: SuppressMessage("Performance", "CA1838:Avoid 'StringBuilder' parameters for P/Invokes", Justification = "breaks icon preview for some reason when using char[]")] [assembly: SuppressMessage("StyleCop.CSharp.SpacingRules", "SA1010:Opening square brackets should be spaced correctly", Justification = "Reviewed")] diff --git a/Interop/NativeMethods.cs b/Interop/NativeMethods.cs index 5cb6d4d..42aa2a7 100644 --- a/Interop/NativeMethods.cs +++ b/Interop/NativeMethods.cs @@ -1,10 +1,8 @@ -using System; -using System.Runtime.InteropServices; -using System.Text; +using System.Runtime.InteropServices; namespace Community.PowerToys.Run.Plugin.Everything.Interop { - public sealed class NativeMethods + public sealed partial class NativeMethods { #region FlagsEnums [Flags] @@ -106,32 +104,33 @@ namespace Community.PowerToys.Run.Plugin.Everything.Interop MAX, } #endregion - internal const string dllName = "Everything64.dll"; - [DllImport(dllName)] - internal static extern uint Everything_GetNumResults(); - [DllImport(dllName, CharSet = CharSet.Unicode)] - internal static extern void Everything_GetResultFullPathName(uint nIndex, StringBuilder lpString, uint nMaxCount); - [DllImport(dllName, CharSet = CharSet.Unicode)] - internal static extern uint Everything_IncRunCountFromFileName(string lpFileName); - [DllImport(dllName)] - internal static extern bool Everything_IsFolderResult(uint index); - [DllImport(dllName)] - internal static extern bool Everything_QueryW(bool bWait); - [DllImport(dllName)] - internal static extern void Everything_SetMax(uint dwMax); - [DllImport(dllName)] - internal static extern void Everything_SetRegex(bool bEnable); - [DllImport(dllName)] - internal static extern void Everything_SetRequestFlags(Request RequestFlags); - [DllImport(dllName, CharSet = CharSet.Unicode)] - internal static extern uint Everything_SetSearchW(string lpSearchString); - [DllImport(dllName)] - internal static extern bool Everything_SetMatchPath(bool bEnable); - [DllImport(dllName)] - internal static extern void Everything_SetSort(Sort SortType); - - [DllImport("Shlwapi.dll", SetLastError = true, CharSet = CharSet.Unicode)] - internal static extern uint AssocQueryString(AssocF flags, AssocStr str, string pszAssoc, string pszExtra, [Out] char[] pszOut, [In][Out] ref uint pcchOut); + [LibraryImport(dllName)] + internal static partial uint Everything_GetLastError(); + [LibraryImport(dllName)] + internal static partial uint Everything_GetNumResults(); + [LibraryImport(dllName, EntryPoint = "Everything_GetResultFullPathNameW", StringMarshalling = StringMarshalling.Utf16)] + internal static partial uint Everything_GetResultFullPathName(uint nIndex, [Out] char[] lpString, uint nMaxCount); + [LibraryImport(dllName, StringMarshalling = StringMarshalling.Utf16)] + internal static partial uint Everything_IncRunCountFromFileName(string lpFileName); + [LibraryImport(dllName)] + [return: MarshalAs(UnmanagedType.Bool)] + internal static partial bool Everything_IsFolderResult(uint index); + [LibraryImport(dllName)] + [return: MarshalAs(UnmanagedType.Bool)] + internal static partial bool Everything_QueryW([MarshalAs(UnmanagedType.Bool)] bool bWait); + [LibraryImport(dllName)] + internal static partial void Everything_SetMax(uint dwMax); + [LibraryImport(dllName)] + internal static partial void Everything_SetRegex([MarshalAs(UnmanagedType.Bool)] bool bEnable); + [LibraryImport(dllName)] + internal static partial void Everything_SetRequestFlags(Request RequestFlags); + [LibraryImport(dllName, StringMarshalling = StringMarshalling.Utf16)] + internal static partial void Everything_SetSearchW(string lpSearchString); + [LibraryImport(dllName)] + [return: MarshalAs(UnmanagedType.Bool)] + internal static partial bool Everything_SetMatchPath([MarshalAs(UnmanagedType.Bool)] bool bEnable); + [LibraryImport(dllName)] + internal static partial void Everything_SetSort(Sort SortType); } } diff --git a/Main.cs b/Main.cs index 3150859..6a4fa8d 100644 --- a/Main.cs +++ b/Main.cs @@ -1,14 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Threading.Tasks; -using System.Windows.Controls; -using Community.PowerToys.Run.Plugin.Everything.Properties; -using Microsoft.PowerToys.Settings.UI.Library; -using Wox.Plugin; -using Wox.Plugin.Logger; -using static Community.PowerToys.Run.Plugin.Everything.Interop.NativeMethods; +using Microsoft.PowerToys.Settings.UI.Library; namespace Community.PowerToys.Run.Plugin.Everything { diff --git a/NSIS/exeCreator.nsi b/NSIS/exeCreator.nsi index d25d5e9..2208e98 100644 --- a/NSIS/exeCreator.nsi +++ b/NSIS/exeCreator.nsi @@ -36,28 +36,27 @@ Page instfiles Section "" - ; Don't terminate processes, helps reduce AV FP ;ExecWait '"$%SystemRoot%\system32\TaskKill.exe" /F /IM ${PT}' - ;ExecWait 'wmic process where name="${PT}" call terminate' - ;Sleep 3000 SetOutPath $INSTDIR GetFullPathName $0 "$EXEDIR\" GetFullPathName $0 $0 - File /r ".\..\..\..\..\..\..\x64\Release\RunPlugins\Everything\*" + File /r "${direct}\*" - ; Also don't launch processes, helps reduce AV FP - ;IfFileExists "$LOCALAPPDATA\PowerToys\${PT}" 0 +2 - ;Exec '"$LOCALAPPDATA\PowerToys\${PT}"' + IfFileExists "$LOCALAPPDATA\PowerToys\${PT}" 0 +2 + Exec '"$LOCALAPPDATA\PowerToys\${PT}"' - ;IfFileExists "$PROGRAMFILES64\PowerToys\${PT}" 0 +2 - ;Exec '"$PROGRAMFILES64\PowerToys\${PT}"' + IfFileExists "$PROGRAMFILES64\PowerToys\${PT}" 0 +2 + Exec '"$PROGRAMFILES64\PowerToys\${PT}"' SectionEnd ;-------------------------------- -; Don't query proceses, helps reduce AV FP -;Function .onInit +Function .onInit + +ExecWait 'wmic process where name="${PT}" call terminate' + ExecWait 'wmic process where name="PowerToys.PowerLauncher.exe" call terminate' + Sleep 200 ; System::Call 'kernel32::CreateMutex(p 0, i 0, t "ACFEF7F6-7856-4BB3-82E3-0877CBB4E9C7") p .r1 ?e' ; Pop $R0 @@ -66,4 +65,4 @@ SectionEnd ; MessageBox MB_OK|MB_ICONEXCLAMATION "The installer is already running." ; Abort -; FunctionEnd \ No newline at end of file +FunctionEnd \ No newline at end of file diff --git a/SearchHelper/IconLoader.cs b/SearchHelper/IconLoader.cs deleted file mode 100644 index 50f16ae..0000000 --- a/SearchHelper/IconLoader.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.IO; -using static Community.PowerToys.Run.Plugin.Everything.Interop.NativeMethods; - -namespace Community.PowerToys.Run.Plugin.Everything.SearchHelper -{ - internal sealed class IconLoader - { - internal static readonly char[] Separator = ['\"', ',']; -#pragma warning disable CS8632 // The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. - internal static string? Icon(string doctype) -#pragma warning restore CS8632 // The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. - { - uint pcchOut = 0; - _ = AssocQueryString(AssocF.NONE, AssocStr.DEFAULTICON, doctype, null, null, ref pcchOut); - char[] pszOut = new char[pcchOut]; - if (AssocQueryString(AssocF.NONE, AssocStr.DEFAULTICON, doctype, null, pszOut, ref pcchOut) != 0) return null; - string doc = Environment.ExpandEnvironmentVariables(new string(pszOut).Split(Separator, StringSplitOptions.RemoveEmptyEntries)[0].Replace("\"", string.Empty, StringComparison.CurrentCulture).Trim()); - - return File.Exists(doc) ? doc : null; - } - } -} diff --git a/Settings.cs b/Settings.cs index cce36c0..d239417 100644 --- a/Settings.cs +++ b/Settings.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Reflection; -using System.Text; - -namespace Community.PowerToys.Run.Plugin.Everything +namespace Community.PowerToys.Run.Plugin.Everything { public class Settings { diff --git a/Update.cs b/Update.cs index cf532e0..66bc9e6 100644 --- a/Update.cs +++ b/Update.cs @@ -1,17 +1,11 @@ -using System; -using System.Diagnostics; -using System.Globalization; -using System.IO; -using System.Net.Http; +using System.Globalization; using System.Text.Json; -using System.Threading.Tasks; -using System.Windows; -using Community.PowerToys.Run.Plugin.Everything.Properties; namespace Community.PowerToys.Run.Plugin.Everything { internal sealed class Update { + private readonly CompositeFormat updateAvailable = CompositeFormat.Parse(Resources.UpdateAvailable); internal async Task UpdateAsync(Version v, Settings s) { string apiUrl = "https://api.github.com/repos/lin-ycv/EverythingPowerToys/releases/latest"; @@ -30,7 +24,7 @@ namespace Community.PowerToys.Run.Plugin.Everything : Version.Parse(root.GetProperty("tag_name").GetString()); if (latest > v && latest.ToString() != s.Skip) { - MessageBoxResult mbox = MessageBox.Show(string.Format(CultureInfo.InvariantCulture, Resources.UpdateAvailable, v, latest), "Updater", MessageBoxButton.YesNoCancel); + MessageBoxResult mbox = MessageBox.Show(string.Format(CultureInfo.InvariantCulture, updateAvailable, v, latest), "Updater", MessageBoxButton.YesNoCancel); if (mbox == MessageBoxResult.Yes && root.TryGetProperty("assets", out JsonElement assets)) { string[] nameUrl = [string.Empty, string.Empty]; diff --git a/plugin.json b/plugin.json index d6580f3..97b7498 100644 --- a/plugin.json +++ b/plugin.json @@ -4,7 +4,7 @@ "IsGlobal": true, "Name": "Everything", "Author": "Yu Chieh (Victor) Lin", - "Version": "0.80.0", + "Version": "0.80.1", "Language": "csharp", "Website": "https://github.com/Lin-ycv/EverythingPowerToys", "ExecuteFileName": "Community.PowerToys.Run.Plugin.Everything.dll",