diff --git a/Plugins/Wox.Plugin.Everything/Everything.dll b/Plugins/Wox.Plugin.Everything/Everything.dll deleted file mode 100644 index e5ea4f8b86..0000000000 Binary files a/Plugins/Wox.Plugin.Everything/Everything.dll and /dev/null differ diff --git a/Plugins/Wox.Plugin.Everything/EverythingAPI.cs b/Plugins/Wox.Plugin.Everything/EverythingAPI.cs index 6eeab81800..a213b3ec07 100644 --- a/Plugins/Wox.Plugin.Everything/EverythingAPI.cs +++ b/Plugins/Wox.Plugin.Everything/EverythingAPI.cs @@ -8,6 +8,7 @@ namespace Wox.Plugin.Everything { public sealed class EverythingAPI { + #region Const const string EVERYTHING_DLL_NAME = "Everything.dll"; #endregion @@ -46,7 +47,7 @@ namespace Wox.Plugin.Everything private static extern StateCode Everything_GetLastError(); [DllImport(EVERYTHING_DLL_NAME)] - private static extern bool Everything_Query(); + private static extern bool Everything_Query(bool bWait); [DllImport(EVERYTHING_DLL_NAME)] private static extern void Everything_SortResultsByPath(); @@ -175,6 +176,27 @@ namespace Wox.Plugin.Everything return Search(keyWord, 0, int.MaxValue); } + private void no() + { + switch (Everything_GetLastError()) + { + case StateCode.CreateThreadError: + throw new CreateThreadException(); + case StateCode.CreateWindowError: + throw new CreateWindowException(); + case StateCode.InvalidCallError: + throw new InvalidCallException(); + case StateCode.InvalidIndexError: + throw new InvalidIndexException(); + case StateCode.IPCError: + throw new IPCErrorException(); + case StateCode.MemoryError: + throw new MemoryErrorException(); + case StateCode.RegisterClassExError: + throw new RegisterClassExException(); + } + } + /// /// Searches the specified key word. /// @@ -196,7 +218,9 @@ namespace Wox.Plugin.Everything Everything_SetSearch(keyWord); Everything_SetOffset(offset); Everything_SetMax(maxCount); - if (!Everything_Query()) + Everything_SetRegex(true); + + if (!Everything_Query(true)) { switch (Everything_GetLastError()) { @@ -218,7 +242,9 @@ namespace Wox.Plugin.Everything yield break; } - const int bufferSize = 256; + Everything_SortResultsByPath(); + + const int bufferSize = 4096; StringBuilder buffer = new StringBuilder(bufferSize); for (int idx = 0; idx < Everything_GetNumResults(); ++idx) { diff --git a/Plugins/Wox.Plugin.Everything/Main.cs b/Plugins/Wox.Plugin.Everything/Main.cs index 203a46c579..fc3ccab710 100644 --- a/Plugins/Wox.Plugin.Everything/Main.cs +++ b/Plugins/Wox.Plugin.Everything/Main.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; @@ -7,6 +8,7 @@ namespace Wox.Plugin.Everything { public class Main : IPlugin { + Wox.Plugin.PluginInitContext context; EverythingAPI api = new EverythingAPI(); public List Query(Query query) @@ -14,20 +16,47 @@ namespace Wox.Plugin.Everything var results = new List(); if (query.ActionParameters.Count > 0 && query.ActionParameters[0].Length > 0) { - IEnumerable enumerable = api.Search(query.ActionParameters[0]); + IEnumerable enumerable = api.Search(query.ActionParameters[0], 0, 100); foreach (string s in enumerable) { Result r = new Result(); - r.Title = s; + r.Title = Path.GetFileName(s); + r.SubTitle = s; + r.Action = () => + { + context.HideApp(); + System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo(); + info.UseShellExecute = true; + info.FileName = s; + try + { + System.Diagnostics.Process.Start(info); + } + catch (Exception ex) + { + context.ShowMsg("Could not start " + r.Title, ex.Message, null); + } + }; results.Add(r); } } + api.Reset(); + return results; } + + [System.Runtime.InteropServices.DllImport("kernel32.dll")] + private static extern int LoadLibrary(string name); - public void Init() + public void Init(Wox.Plugin.PluginInitContext context) { + this.context = context; + + LoadLibrary(Path.Combine( + Path.Combine(context.PluginMetadata.PluginDirecotry, (IntPtr.Size == 4) ? "x86" : "x64"), + "Everything.dll" + )); //init everything } } diff --git a/Plugins/Wox.Plugin.Everything/Wox.Plugin.Everything.csproj b/Plugins/Wox.Plugin.Everything/Wox.Plugin.Everything.csproj index 2c0e35c8d9..9397bc1a02 100644 --- a/Plugins/Wox.Plugin.Everything/Wox.Plugin.Everything.csproj +++ b/Plugins/Wox.Plugin.Everything/Wox.Plugin.Everything.csproj @@ -48,6 +48,9 @@ prompt MinimumRecommendedRules.ruleset + + + @@ -76,7 +79,8 @@ xcopy /Y $(TargetDir)$(TargetFileName) $(SolutionDir)Wox\bin\Debug\Plugins\Everything\ xcopy /Y $(TargetDir)plugin.ini $(SolutionDir)Wox\bin\Debug\Plugins\Everything\ -xcopy /Y $(ProjectDir)Everything.dll $(SolutionDir)Wox\bin\Debug\Plugins\Everything\ +xcopy /Y $(ProjectDir)x86\Everything.dll $(SolutionDir)Wox\bin\Debug\Plugins\Everything\x86\ +xcopy /Y $(ProjectDir)x64\Everything.dll $(SolutionDir)Wox\bin\Debug\Plugins\Everything\x64\