mirror of
https://github.com/lin-ycv/EverythingPowerToys.git
synced 2025-01-08 11:57:59 +08:00
[Run] Basic Everything integration
This commit is contained in:
commit
a43385aeaa
109
Community.PowerToys.Run.Plugin.Everything.csproj
Normal file
109
Community.PowerToys.Run.Plugin.Everything.csproj
Normal file
@ -0,0 +1,109 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
|
||||
<Import Project="..\..\..\..\Version.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<ProjectGuid>{64467D32-4786-4ADD-9B77-FBF3C965D3D1}</ProjectGuid>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Community.PowerToys.Run.Plugin.Everything</RootNamespace>
|
||||
<AssemblyName>Community.PowerToys.Run.Plugin.Everything</AssemblyName>
|
||||
<Version>$(Version).0</Version>
|
||||
<useWPF>true</useWPF>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
|
||||
<Platforms>x64</Platforms>
|
||||
<NeutralLanguage>en-US</NeutralLanguage>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>..\..\..\..\..\x64\Debug\modules\launcher\Plugins\Everything\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<LangVersion>7.3</LangVersion>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Optimize>false</Optimize>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<OutputPath>..\..\..\..\..\x64\Release\modules\launcher\Plugins\Everything\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<LangVersion>7.3</LangVersion>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="..\..\..\..\codeAnalysis\GlobalSuppressions.cs">
|
||||
<Link>GlobalSuppressions.cs</Link>
|
||||
</Compile>
|
||||
<AdditionalFiles Include="..\..\..\..\codeAnalysis\StyleCop.json">
|
||||
<Link>StyleCop.json</Link>
|
||||
</AdditionalFiles>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Wox.Infrastructure\Wox.Infrastructure.csproj">
|
||||
<Private>false</Private>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Wox.Plugin\Wox.Plugin.csproj">
|
||||
<Private>false</Private>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="plugin.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="JetBrains.Annotations" Version="2020.1.0" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.3.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.Runtime" Version="4.3.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="Properties\Resources.Designer.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Update="Properties\Resources.resx">
|
||||
<Generator>PublicResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Everything64.dll">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Images\Everything.dark.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Images\Everything.light.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
BIN
Everything64.dll
Normal file
BIN
Everything64.dll
Normal file
Binary file not shown.
5
GlobalSuppressions1.cs
Normal file
5
GlobalSuppressions1.cs
Normal file
@ -0,0 +1,5 @@
|
||||
// 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.Diagnostics.CodeAnalysis;
|
BIN
Images/Everything.dark.png
Normal file
BIN
Images/Everything.dark.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
BIN
Images/Everything.light.png
Normal file
BIN
Images/Everything.light.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
BIN
Images/Warning.dark.png
Normal file
BIN
Images/Warning.dark.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 566 B |
BIN
Images/Warning.light.png
Normal file
BIN
Images/Warning.light.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 580 B |
120
Main.cs
Normal file
120
Main.cs
Normal file
@ -0,0 +1,120 @@
|
||||
// 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.Windows.Controls;
|
||||
using ManagedCommon;
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
using Wox.Infrastructure;
|
||||
using Wox.Plugin;
|
||||
using Wox.Plugin.Logger;
|
||||
|
||||
namespace Community.PowerToys.Run.Plugin.Everything
|
||||
{
|
||||
public class Main : IPlugin, IDisposable, IDelayedExecutionPlugin
|
||||
{
|
||||
private readonly string reservedStringPattern = @"^[\/\\\$\%]+$|^.*[<>].*$";
|
||||
|
||||
public string Name => Properties.Resources.plugin_name;
|
||||
|
||||
public string Description => Properties.Resources.plugin_description;
|
||||
|
||||
private PluginInitContext _context;
|
||||
private bool disposedValue;
|
||||
|
||||
private string _warningIconPath;
|
||||
|
||||
private string IconPath { get; set; }
|
||||
|
||||
public void Init(PluginInitContext context)
|
||||
{
|
||||
_context = context ?? throw new ArgumentNullException(nameof(context));
|
||||
_context.API.ThemeChanged += OnThemeChanged;
|
||||
UpdateIconPath(_context.API.GetCurrentTheme());
|
||||
}
|
||||
|
||||
public List<Result> Query(Query query)
|
||||
{
|
||||
return new List<Result>();
|
||||
}
|
||||
|
||||
[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")]
|
||||
public List<Result> Query(Query query, bool isFullQuery)
|
||||
{
|
||||
List<Result> results = new List<Result>();
|
||||
if (query != null && !string.IsNullOrEmpty(query.Search))
|
||||
{
|
||||
var searchQuery = query.Search;
|
||||
|
||||
var regexMatch = Regex.Match(searchQuery, reservedStringPattern);
|
||||
|
||||
if (!regexMatch.Success)
|
||||
{
|
||||
try
|
||||
{
|
||||
results.AddRange(NativeMethods.EverythingSearch(searchQuery));
|
||||
}
|
||||
catch (ApplicationException)
|
||||
{
|
||||
results.Add(new Result
|
||||
{
|
||||
Title = Properties.Resources.Everything_not_running,
|
||||
IcoPath = _warningIconPath,
|
||||
});
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Exception("Something failed", e, GetType());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
private void OnThemeChanged(Theme oldtheme, Theme newTheme)
|
||||
{
|
||||
UpdateIconPath(newTheme);
|
||||
}
|
||||
|
||||
private void UpdateIconPath(Theme theme)
|
||||
{
|
||||
if (theme == Theme.Light || theme == Theme.HighContrastWhite)
|
||||
{
|
||||
IconPath = "Images/Everything.light.png";
|
||||
_warningIconPath = "Images/Warning.light.png";
|
||||
}
|
||||
else
|
||||
{
|
||||
IconPath = "Images/Everything.dark.png";
|
||||
_warningIconPath = "Images/Warning.dark.png";
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (!disposedValue)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
}
|
||||
|
||||
disposedValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
|
||||
Dispose(disposing: true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
}
|
239
NativeMethods.cs
Normal file
239
NativeMethods.cs
Normal file
@ -0,0 +1,239 @@
|
||||
// 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.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using Wox.Plugin;
|
||||
|
||||
namespace Community.PowerToys.Run.Plugin.Everything
|
||||
{
|
||||
internal static class NativeMethods
|
||||
{
|
||||
[SuppressMessage("Performance", "CA1823:Avoid unused private fields", Justification = "CnP")]
|
||||
internal const int EVERYTHING_OK = 0;
|
||||
internal const int EVERYTHING_ERROR_MEMORY = 1;
|
||||
internal const int EVERYTHING_ERROR_IPC = 2;
|
||||
internal const int EVERYTHING_ERROR_REGISTERCLASSEX = 3;
|
||||
internal const int EVERYTHING_ERROR_CREATEWINDOW = 4;
|
||||
internal const int EVERYTHING_ERROR_CREATETHREAD = 5;
|
||||
internal const int EVERYTHING_ERROR_INVALIDINDEX = 6;
|
||||
internal const int EVERYTHING_ERROR_INVALIDCALL = 7;
|
||||
|
||||
internal const int EVERYTHING_REQUEST_FILE_NAME = 0x00000001;
|
||||
internal const int EVERYTHING_REQUEST_PATH = 0x00000002;
|
||||
internal const int EVERYTHING_REQUEST_FULL_PATH_AND_FILE_NAME = 0x00000004;
|
||||
internal const int EVERYTHING_REQUEST_EXTENSION = 0x00000008;
|
||||
internal const int EVERYTHING_REQUEST_SIZE = 0x00000010;
|
||||
internal const int EVERYTHING_REQUEST_DATE_CREATED = 0x00000020;
|
||||
internal const int EVERYTHING_REQUEST_DATE_MODIFIED = 0x00000040;
|
||||
internal const int EVERYTHING_REQUEST_DATE_ACCESSED = 0x00000080;
|
||||
internal const int EVERYTHING_REQUEST_ATTRIBUTES = 0x00000100;
|
||||
internal const int EVERYTHING_REQUEST_FILE_LIST_FILE_NAME = 0x00000200;
|
||||
internal const int EVERYTHING_REQUEST_RUN_COUNT = 0x00000400;
|
||||
internal const int EVERYTHING_REQUEST_DATE_RUN = 0x00000800;
|
||||
internal const int EVERYTHING_REQUEST_DATE_RECENTLY_CHANGED = 0x00001000;
|
||||
internal const int EVERYTHING_REQUEST_HIGHLIGHTED_FILE_NAME = 0x00002000;
|
||||
internal const int EVERYTHING_REQUEST_HIGHLIGHTED_PATH = 0x00004000;
|
||||
internal const int EVERYTHING_REQUEST_HIGHLIGHTED_FULL_PATH_AND_FILE_NAME = 0x00008000;
|
||||
|
||||
internal const int EVERYTHING_SORT_NAME_ASCENDING = 1;
|
||||
internal const int EVERYTHING_SORT_NAME_DESCENDING = 2;
|
||||
internal const int EVERYTHING_SORT_PATH_ASCENDING = 3;
|
||||
internal const int EVERYTHING_SORT_PATH_DESCENDING = 4;
|
||||
internal const int EVERYTHING_SORT_SIZE_ASCENDING = 5;
|
||||
internal const int EVERYTHING_SORT_SIZE_DESCENDING = 6;
|
||||
internal const int EVERYTHING_SORT_EXTENSION_ASCENDING = 7;
|
||||
internal const int EVERYTHING_SORT_EXTENSION_DESCENDING = 8;
|
||||
internal const int EVERYTHING_SORT_TYPE_NAME_ASCENDING = 9;
|
||||
internal const int EVERYTHING_SORT_TYPE_NAME_DESCENDING = 10;
|
||||
internal const int EVERYTHING_SORT_DATE_CREATED_ASCENDING = 11;
|
||||
internal const int EVERYTHING_SORT_DATE_CREATED_DESCENDING = 12;
|
||||
internal const int EVERYTHING_SORT_DATE_MODIFIED_ASCENDING = 13;
|
||||
internal const int EVERYTHING_SORT_DATE_MODIFIED_DESCENDING = 14;
|
||||
internal const int EVERYTHING_SORT_ATTRIBUTES_ASCENDING = 15;
|
||||
internal const int EVERYTHING_SORT_ATTRIBUTES_DESCENDING = 16;
|
||||
internal const int EVERYTHING_SORT_FILE_LIST_FILENAME_ASCENDING = 17;
|
||||
internal const int EVERYTHING_SORT_FILE_LIST_FILENAME_DESCENDING = 18;
|
||||
internal const int EVERYTHING_SORT_RUN_COUNT_ASCENDING = 19;
|
||||
internal const int EVERYTHING_SORT_RUN_COUNT_DESCENDING = 20;
|
||||
internal const int EVERYTHING_SORT_DATE_RECENTLY_CHANGED_ASCENDING = 21;
|
||||
internal const int EVERYTHING_SORT_DATE_RECENTLY_CHANGED_DESCENDING = 22;
|
||||
internal const int EVERYTHING_SORT_DATE_ACCESSED_ASCENDING = 23;
|
||||
internal const int EVERYTHING_SORT_DATE_ACCESSED_DESCENDING = 24;
|
||||
internal const int EVERYTHING_SORT_DATE_RUN_ASCENDING = 25;
|
||||
internal const int EVERYTHING_SORT_DATE_RUN_DESCENDING = 26;
|
||||
|
||||
internal const int EVERYTHING_TARGET_MACHINE_X86 = 1;
|
||||
internal const int EVERYTHING_TARGET_MACHINE_X64 = 2;
|
||||
internal const int EVERYTHING_TARGET_MACHINE_ARM = 3;
|
||||
private const string dllName = "Everything64.dll";
|
||||
|
||||
#pragma warning disable SA1516 // Elements should be separated by blank line
|
||||
[DllImport(dllName, CharSet = CharSet.Unicode)]
|
||||
public static extern uint Everything_SetSearchW(string lpSearchString);
|
||||
[DllImport(dllName)]
|
||||
public static extern void Everything_SetMatchPath(bool bEnable);
|
||||
[DllImport(dllName)]
|
||||
public static extern void Everything_SetMatchCase(bool bEnable);
|
||||
[DllImport(dllName)]
|
||||
public static extern void Everything_SetMatchWholeWord(bool bEnable);
|
||||
[DllImport(dllName)]
|
||||
public static extern void Everything_SetRegex(bool bEnable);
|
||||
[DllImport(dllName)]
|
||||
public static extern void Everything_SetMax(uint dwMax);
|
||||
[DllImport(dllName)]
|
||||
public static extern void Everything_SetOffset(uint dwOffset);
|
||||
|
||||
[DllImport(dllName)]
|
||||
public static extern bool Everything_GetMatchPath();
|
||||
[DllImport(dllName)]
|
||||
public static extern bool Everything_GetMatchCase();
|
||||
[DllImport(dllName)]
|
||||
public static extern bool Everything_GetMatchWholeWord();
|
||||
[DllImport(dllName)]
|
||||
public static extern bool Everything_GetRegex();
|
||||
[DllImport(dllName)]
|
||||
public static extern uint Everything_GetMax();
|
||||
[DllImport(dllName)]
|
||||
public static extern uint Everything_GetOffset();
|
||||
[DllImport(dllName)]
|
||||
public static extern IntPtr Everything_GetSearchW();
|
||||
[DllImport(dllName)]
|
||||
public static extern uint Everything_GetLastError();
|
||||
[DllImport(dllName)]
|
||||
public static extern bool Everything_QueryW(bool bWait);
|
||||
[DllImport(dllName)]
|
||||
public static extern void Everything_SortResultsByPath();
|
||||
[DllImport(dllName)]
|
||||
public static extern uint Everything_GetNumFileResults();
|
||||
[DllImport(dllName)]
|
||||
public static extern uint Everything_GetNumFolderResults();
|
||||
[DllImport(dllName)]
|
||||
public static extern uint Everything_GetNumResults();
|
||||
[DllImport(dllName)]
|
||||
public static extern uint Everything_GetTotFileResults();
|
||||
[DllImport(dllName)]
|
||||
public static extern uint Everything_GetTotFolderResults();
|
||||
[DllImport(dllName)]
|
||||
public static extern uint Everything_GetTotResults();
|
||||
[DllImport(dllName)]
|
||||
public static extern bool Everything_IsVolumeResult(uint nIndex);
|
||||
[DllImport(dllName)]
|
||||
public static extern bool Everything_IsFolderResult(uint nIndex);
|
||||
[DllImport(dllName)]
|
||||
public static extern bool Everything_IsFileResult(uint nIndex);
|
||||
[DllImport(dllName, CharSet = CharSet.Unicode)]
|
||||
public static extern void Everything_GetResultFullPathName(uint nIndex, StringBuilder lpString, uint nMaxCount);
|
||||
[DllImport(dllName)]
|
||||
public static extern void Everything_Reset();
|
||||
[DllImport(dllName, CharSet = CharSet.Unicode)]
|
||||
public static extern IntPtr Everything_GetResultFileName(uint nIndex);
|
||||
[DllImport(dllName)]
|
||||
public static extern void Everything_SetSort(uint dwSortType);
|
||||
[DllImport(dllName)]
|
||||
public static extern uint Everything_GetSort();
|
||||
[DllImport(dllName)]
|
||||
public static extern uint Everything_GetResultListSort();
|
||||
[DllImport(dllName)]
|
||||
public static extern IntPtr Everything_GetResultPath(uint nIndex);
|
||||
[DllImport(dllName)]
|
||||
public static extern void Everything_SetRequestFlags(uint dwRequestFlags);
|
||||
[DllImport(dllName)]
|
||||
public static extern uint Everything_GetRequestFlags();
|
||||
[DllImport(dllName)]
|
||||
public static extern uint Everything_GetResultListRequestFlags();
|
||||
[DllImport(dllName, CharSet = CharSet.Unicode)]
|
||||
public static extern IntPtr Everything_GetResultExtension(uint nIndex);
|
||||
[DllImport(dllName)]
|
||||
public static extern bool Everything_GetResultSize(uint nIndex, out long lpFileSize);
|
||||
[DllImport(dllName)]
|
||||
public static extern bool Everything_GetResultDateCreated(uint nIndex, out long lpFileTime);
|
||||
[DllImport(dllName)]
|
||||
public static extern bool Everything_GetResultDateModified(uint nIndex, out long lpFileTime);
|
||||
[DllImport(dllName)]
|
||||
public static extern bool Everything_GetResultDateAccessed(uint nIndex, out long lpFileTime);
|
||||
[DllImport(dllName)]
|
||||
public static extern uint Everything_GetResultAttributes(uint nIndex);
|
||||
[DllImport(dllName, CharSet = CharSet.Unicode)]
|
||||
public static extern IntPtr Everything_GetResultFileListFileName(uint nIndex);
|
||||
[DllImport(dllName)]
|
||||
public static extern uint Everything_GetResultRunCount(uint nIndex);
|
||||
[DllImport(dllName)]
|
||||
public static extern bool Everything_GetResultDateRun(uint nIndex, out long lpFileTime);
|
||||
[DllImport(dllName)]
|
||||
public static extern bool Everything_GetResultDateRecentlyChanged(uint nIndex, out long lpFileTime);
|
||||
[DllImport(dllName, CharSet = CharSet.Unicode)]
|
||||
public static extern IntPtr Everything_GetResultHighlightedFileName(uint nIndex);
|
||||
[DllImport(dllName, CharSet = CharSet.Unicode)]
|
||||
public static extern IntPtr Everything_GetResultHighlightedPath(uint nIndex);
|
||||
[DllImport(dllName, CharSet = CharSet.Unicode)]
|
||||
public static extern IntPtr Everything_GetResultHighlightedFullPathAndFileName(uint nIndex);
|
||||
[DllImport(dllName, CharSet = CharSet.Unicode)]
|
||||
public static extern uint Everything_GetRunCountFromFileName(string lpFileName);
|
||||
[DllImport(dllName, CharSet = CharSet.Unicode)]
|
||||
public static extern bool Everything_SetRunCountFromFileName(string lpFileName, uint dwRunCount);
|
||||
[DllImport(dllName, CharSet = CharSet.Unicode)]
|
||||
public static extern uint Everything_IncRunCountFromFileName(string lpFileName);
|
||||
#pragma warning restore SA1516 // Elements should be separated by blank line
|
||||
|
||||
public static IEnumerable<Result> EverythingSearch(string qry)
|
||||
{
|
||||
_ = Everything_SetSearchW(qry);
|
||||
Everything_SetRequestFlags(EVERYTHING_REQUEST_FILE_NAME | EVERYTHING_REQUEST_PATH | EVERYTHING_REQUEST_DATE_MODIFIED | EVERYTHING_REQUEST_SIZE);
|
||||
Everything_SetSort(EVERYTHING_SORT_DATE_MODIFIED_DESCENDING);
|
||||
Everything_SetMax(20);
|
||||
Everything_SetRegex(false);
|
||||
if (qry.StartsWith("@", StringComparison.CurrentCulture))
|
||||
{
|
||||
Everything_SetRegex(true);
|
||||
qry = qry.Substring(1);
|
||||
}
|
||||
|
||||
_ = Everything_QueryW(true);
|
||||
uint resultCount = Everything_GetNumResults();
|
||||
|
||||
for (uint i = 0; i < resultCount; i++)
|
||||
{
|
||||
_ = Everything_GetResultDateModified(i, out long date_modified);
|
||||
_ = Everything_GetResultSize(i, out long size);
|
||||
string fileName = Marshal.PtrToStringUni(Everything_GetResultFileName(i));
|
||||
string filePath = Marshal.PtrToStringUni(Everything_GetResultPath(i));
|
||||
|
||||
yield return new Result()
|
||||
{
|
||||
Title = fileName,
|
||||
ToolTipData = new ToolTipData(fileName, filePath),
|
||||
SubTitle = Properties.Resources.plugin_name,
|
||||
IcoPath = filePath,
|
||||
Score = (int)(Everything_GetTotResults() - i),
|
||||
Action = e =>
|
||||
{
|
||||
using (Process process = new Process())
|
||||
{
|
||||
process.StartInfo.FileName = System.IO.Path.Combine(filePath, fileName);
|
||||
process.StartInfo.WorkingDirectory = filePath;
|
||||
process.StartInfo.Arguments = string.Empty;
|
||||
|
||||
process.StartInfo.UseShellExecute = true;
|
||||
|
||||
try
|
||||
{
|
||||
_ = process.Start();
|
||||
return true;
|
||||
}
|
||||
catch (System.ComponentModel.Win32Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
90
Properties/Resources.Designer.cs
generated
Normal file
90
Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,90 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 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.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Community.PowerToys.Run.Plugin.Everything.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// 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() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
public static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Everything is not running.
|
||||
/// </summary>
|
||||
public static string Everything_not_running {
|
||||
get {
|
||||
return ResourceManager.GetString("Everything_not_running", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Get search results from Everything.
|
||||
/// </summary>
|
||||
public static string plugin_description {
|
||||
get {
|
||||
return ResourceManager.GetString("plugin_description", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Everything.
|
||||
/// </summary>
|
||||
public static string plugin_name {
|
||||
get {
|
||||
return ResourceManager.GetString("plugin_name", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
129
Properties/Resources.resx
Normal file
129
Properties/Resources.resx
Normal file
@ -0,0 +1,129 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="Everything_not_running" xml:space="preserve">
|
||||
<value>Everything is not running</value>
|
||||
</data>
|
||||
<data name="plugin_description" xml:space="preserve">
|
||||
<value>Get search results from Everything</value>
|
||||
</data>
|
||||
<data name="plugin_name" xml:space="preserve">
|
||||
<value>Everything</value>
|
||||
</data>
|
||||
</root>
|
13
plugin.json
Normal file
13
plugin.json
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"ID": "A86867E2D932459CBD77D176373DD657",
|
||||
"ActionKeyword": "@",
|
||||
"IsGlobal": true,
|
||||
"Name": "Everything",
|
||||
"Author": "Yu Chieh (Victor) Lin",
|
||||
"Version": "0.1.0",
|
||||
"Language": "csharp",
|
||||
"Website": "https://aka.ms/powertoys",
|
||||
"ExecuteFileName": "Community.PowerToys.Run.Plugin.Everything.dll",
|
||||
"IcoPathDark": "Images\\Everything.dark.png",
|
||||
"IcoPathLight": "Images\\Everything.light.png"
|
||||
}
|
Loading…
Reference in New Issue
Block a user