mirror of
https://github.com/lin-ycv/EverythingPowerToys.git
synced 2025-01-08 11:57:59 +08:00
v63
This commit is contained in:
parent
8dd6d86727
commit
6d8c0e81e3
2
.github/workflows/chocolately.yml
vendored
2
.github/workflows/chocolately.yml
vendored
@ -2,7 +2,7 @@ name: sync to chocolately
|
||||
|
||||
on:
|
||||
release:
|
||||
type: [published]
|
||||
types: [published]
|
||||
|
||||
workflow_dispatch:
|
||||
|
||||
|
16
Main.cs
16
Main.cs
@ -24,14 +24,12 @@ namespace Community.PowerToys.Run.Plugin.Everything
|
||||
{
|
||||
public class Main : IPlugin, IDisposable, IDelayedExecutionPlugin, IContextMenu, ISettingProvider, IPluginI18n
|
||||
{
|
||||
private const string AltIcon = nameof(AltIcon);
|
||||
private const string RegEx = nameof(RegEx);
|
||||
private const string NoPreview = nameof(NoPreview);
|
||||
private const string MatchPath = nameof(MatchPath);
|
||||
private readonly string reservedStringPattern = @"^[\/\\\$\%]+$|^.*[<>].*$";
|
||||
private bool regEx;
|
||||
private bool preview;
|
||||
private bool altIcon;
|
||||
private bool matchPath;
|
||||
|
||||
#pragma warning disable SA1401
|
||||
@ -47,12 +45,6 @@ namespace Community.PowerToys.Run.Plugin.Everything
|
||||
|
||||
public IEnumerable<PluginAdditionalOption> AdditionalOptions => new List<PluginAdditionalOption>()
|
||||
{
|
||||
new PluginAdditionalOption()
|
||||
{
|
||||
Key = AltIcon,
|
||||
DisplayLabel = Resources.AltIcon,
|
||||
Value = false,
|
||||
},
|
||||
new PluginAdditionalOption()
|
||||
{
|
||||
Key = MatchPath,
|
||||
@ -75,7 +67,7 @@ namespace Community.PowerToys.Run.Plugin.Everything
|
||||
{
|
||||
Key = Debug,
|
||||
DisplayLabel = "Log debug data",
|
||||
Value = true,
|
||||
Value = false,
|
||||
},
|
||||
};
|
||||
|
||||
@ -109,7 +101,7 @@ namespace Community.PowerToys.Run.Plugin.Everything
|
||||
{
|
||||
try
|
||||
{
|
||||
results.AddRange(EverythingSearch(searchQuery, this.preview, this.altIcon, debug));
|
||||
results.AddRange(EverythingSearch(searchQuery, this.preview, this.matchPath, debug));
|
||||
}
|
||||
catch (System.ComponentModel.Win32Exception)
|
||||
{
|
||||
@ -146,7 +138,6 @@ namespace Community.PowerToys.Run.Plugin.Everything
|
||||
{
|
||||
var regX = false;
|
||||
var nopreview = false;
|
||||
var alt = false;
|
||||
var debuging = false;
|
||||
var searchpath = false;
|
||||
|
||||
@ -154,7 +145,6 @@ namespace Community.PowerToys.Run.Plugin.Everything
|
||||
{
|
||||
regX = settings.AdditionalOptions.FirstOrDefault(x => x.Key == RegEx)?.Value ?? false;
|
||||
nopreview = settings.AdditionalOptions.FirstOrDefault(x => x.Key == NoPreview)?.Value ?? false;
|
||||
alt = settings.AdditionalOptions.FirstOrDefault(x => x.Key == AltIcon)?.Value ?? false;
|
||||
debuging = settings.AdditionalOptions.FirstOrDefault(x => x.Key == Debug)?.Value ?? true;
|
||||
searchpath = settings.AdditionalOptions.FirstOrDefault(x => x.Key == MatchPath)?.Value ?? false;
|
||||
}
|
||||
@ -162,7 +152,7 @@ namespace Community.PowerToys.Run.Plugin.Everything
|
||||
this.regEx = regX;
|
||||
Everything_SetRegex(this.regEx);
|
||||
this.preview = nopreview;
|
||||
this.altIcon = alt;
|
||||
|
||||
this.debug = debuging;
|
||||
this.matchPath = searchpath;
|
||||
Everything_SetMatchPath(this.matchPath);
|
||||
|
@ -148,7 +148,6 @@ namespace Community.PowerToys.Run.Plugin.Everything
|
||||
private static uint max = 20;
|
||||
private static Sort sort = Sort.DATE_MODIFIED_DESCENDING;
|
||||
private static Dictionary<string, string> filters = new Dictionary<string, string>();
|
||||
private static bool firstrun = true;
|
||||
|
||||
public static void EverythingSetup(bool debug)
|
||||
{
|
||||
@ -192,12 +191,15 @@ namespace Community.PowerToys.Run.Plugin.Everything
|
||||
}
|
||||
}
|
||||
|
||||
public static IEnumerable<Result> EverythingSearch(string qry, bool preview, bool legacy, bool debug)
|
||||
public static IEnumerable<Result> EverythingSearch(string qry, bool preview, bool matchpath, bool debug)
|
||||
{
|
||||
string orgqry = qry;
|
||||
if (!preview && legacy && firstrun)
|
||||
Icons = GetFileTypeAndIcon();
|
||||
Everything_SetMax(max);
|
||||
if (qry.Contains('\"') && !matchpath)
|
||||
{
|
||||
Everything_SetMatchPath(true);
|
||||
}
|
||||
|
||||
if (qry.Contains(':'))
|
||||
{
|
||||
string[] nqry = qry.Split(':');
|
||||
@ -214,6 +216,11 @@ namespace Community.PowerToys.Run.Plugin.Everything
|
||||
throw new Win32Exception("Unable to Query");
|
||||
}
|
||||
|
||||
if (qry.Contains('\"') && !matchpath)
|
||||
{
|
||||
Everything_SetMatchPath(false);
|
||||
}
|
||||
|
||||
uint resultCount = Everything_GetNumResults();
|
||||
|
||||
if (debug)
|
||||
@ -245,9 +252,7 @@ namespace Community.PowerToys.Run.Plugin.Everything
|
||||
SubTitle = Resources.plugin_name + ": " + fullPath,
|
||||
|
||||
IcoPath = isFolder ? "Images/folder.png" : (preview ?
|
||||
fullPath :
|
||||
(string)((legacy ? Icons[ext] : Icon(ext)) ??
|
||||
"Images/file.png")),
|
||||
fullPath : (Icon(ext) ?? "Images/file.png")),
|
||||
ContextData = new SearchResult()
|
||||
{
|
||||
Path = fullPath,
|
||||
@ -285,84 +290,10 @@ namespace Community.PowerToys.Run.Plugin.Everything
|
||||
uint pcchOut = 0;
|
||||
_ = AssocQueryString(AssocF.NONE, AssocStr.DEFAULTICON, doctype, null, null, ref pcchOut);
|
||||
char[] pszOut = new char[pcchOut];
|
||||
_ = AssocQueryString(AssocF.NONE, AssocStr.DEFAULTICON, doctype, null, pszOut, ref pcchOut);
|
||||
if (AssocQueryString(AssocF.NONE, AssocStr.DEFAULTICON, doctype, null, pszOut, ref pcchOut) != 0) return null;
|
||||
string doc = Environment.ExpandEnvironmentVariables(new string(pszOut).Split(new char[] { '\"', ',' }, StringSplitOptions.RemoveEmptyEntries)[0].Replace("\"", string.Empty, StringComparison.CurrentCulture).Trim());
|
||||
|
||||
if (File.Exists(doc))
|
||||
return doc;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
//Manually traverse the registry
|
||||
private static Hashtable Icons = new Hashtable();
|
||||
internal static Hashtable GetFileTypeAndIcon()
|
||||
{
|
||||
Hashtable iconsInfo = new Hashtable(StringComparer.CurrentCultureIgnoreCase);
|
||||
try
|
||||
{
|
||||
using (RegistryKey rkRoot = RegistryKey.OpenBaseKey(RegistryHive.ClassesRoot, RegistryView.Registry64))
|
||||
{
|
||||
FindExt(rkRoot);
|
||||
}
|
||||
|
||||
using (RegistryKey rkRoot = RegistryKey.OpenBaseKey(RegistryHive.ClassesRoot, RegistryView.Registry32))
|
||||
{
|
||||
FindExt(rkRoot);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Exception(e.Message, e, typeof(NativeMethods));
|
||||
}
|
||||
|
||||
firstrun = false;
|
||||
return iconsInfo;
|
||||
|
||||
void FindExt(RegistryKey rkRoot)
|
||||
{
|
||||
foreach (string keyName in rkRoot.GetSubKeyNames())
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(keyName) || keyName[0] != '.' || iconsInfo.ContainsKey(keyName))
|
||||
continue;
|
||||
|
||||
try
|
||||
{
|
||||
object defaultValue = null;
|
||||
using (RegistryKey rkKey = rkRoot.OpenSubKey(keyName))
|
||||
{
|
||||
defaultValue = rkKey.GetValue(string.Empty);
|
||||
if (defaultValue == null)
|
||||
continue;
|
||||
}
|
||||
|
||||
Log.Info((defaultValue == null) + string.Empty, typeof(NativeMethods));
|
||||
|
||||
object iconValue = null;
|
||||
using (RegistryKey rkIcon = rkRoot.OpenSubKey(defaultValue.ToString() + "\\defaulticon"), rkOpen = rkRoot.OpenSubKey(defaultValue.ToString() + "\\shell\\Open\\command"))
|
||||
{
|
||||
iconValue = (rkIcon == null) ? rkOpen?.GetValue(string.Empty) : rkIcon.GetValue(string.Empty);
|
||||
if (iconValue == null)
|
||||
continue;
|
||||
}
|
||||
|
||||
Log.Info((iconValue == null) + string.Empty, typeof(NativeMethods));
|
||||
|
||||
string[] path = iconValue.ToString().Split(new char[] { '\"', ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
if (path.Length > 0 && path[0].Contains('.'))
|
||||
{
|
||||
string fileParam = Environment.ExpandEnvironmentVariables(path[0].Replace("\"", string.Empty, StringComparison.CurrentCulture).Trim());
|
||||
if (!fileParam.EndsWith("dll", StringComparison.CurrentCulture))
|
||||
iconsInfo.Add(keyName, fileParam);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Exception(keyName + ":" + e.ToString(), e, typeof(NativeMethods));
|
||||
continue; // something wrong with this key, move on
|
||||
}
|
||||
}
|
||||
}
|
||||
return File.Exists(doc) ? doc : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
9
Properties/Resources.Designer.cs
generated
9
Properties/Resources.Designer.cs
generated
@ -60,15 +60,6 @@ namespace Community.PowerToys.Run.Plugin.Everything.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Alternative - if the icon for your files aren't displaying correctly, try this alternative method of getting icons..
|
||||
/// </summary>
|
||||
public static string AltIcon {
|
||||
get {
|
||||
return ResourceManager.GetString("AltIcon", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Fail to set text in clipboard.
|
||||
/// </summary>
|
||||
|
@ -117,9 +117,6 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="AltIcon" xml:space="preserve">
|
||||
<value>Alternative - if the icon for your files aren't displaying correctly, try this alternative method of getting icons.</value>
|
||||
</data>
|
||||
<data name="clipboard_failed" xml:space="preserve">
|
||||
<value>Fail to set text in clipboard</value>
|
||||
</data>
|
||||
|
@ -117,9 +117,6 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="AltIcon" xml:space="preserve">
|
||||
<value>替代图示</value>
|
||||
</data>
|
||||
<data name="clipboard_failed" xml:space="preserve">
|
||||
<value>无法拷贝路径</value>
|
||||
</data>
|
||||
|
@ -117,9 +117,6 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="AltIcon" xml:space="preserve">
|
||||
<value>變更圖示邏輯</value>
|
||||
</data>
|
||||
<data name="clipboard_failed" xml:space="preserve">
|
||||
<value>複製到剪貼簿失敗</value>
|
||||
</data>
|
||||
|
@ -4,7 +4,7 @@
|
||||
"IsGlobal": true,
|
||||
"Name": "Everything",
|
||||
"Author": "Yu Chieh (Victor) Lin",
|
||||
"Version": "0.61.1",
|
||||
"Version": "0.63.0",
|
||||
"Language": "csharp",
|
||||
"Website": "https://github.com/lin-ycv/EverythingPowerToys",
|
||||
"ExecuteFileName": "Community.PowerToys.Run.Plugin.Everything.dll",
|
||||
|
Loading…
Reference in New Issue
Block a user