diff --git a/Plugins/Wox.Plugin.Program/Programs.cs b/Plugins/Wox.Plugin.Program/Programs.cs index 31f8d9b53a..7028848b83 100644 --- a/Plugins/Wox.Plugin.Program/Programs.cs +++ b/Plugins/Wox.Plugin.Program/Programs.cs @@ -8,6 +8,7 @@ using System.Threading; using System.Windows; using Wox.Infrastructure; using Wox.Plugin.Program.ProgramSources; +using IWshRuntimeLibrary; namespace Wox.Plugin.Program { @@ -55,11 +56,40 @@ namespace Wox.Plugin.Program return true; }, IcoPath = "Images/cmd.png" + }, + new Result() + { + Title = "Open Containing Folder", + Action = _ => + { + context.API.HideApp(); + String Path=c.ExecutePath; + //check if shortcut + if (Path.EndsWith(".lnk")) + { + //get location of shortcut + Path = ResolveShortcut(Path); + } + //get parent folder + Path=System.IO.Directory.GetParent(Path).FullName; + //open the folder + context.API.ShellRun("explorer.exe "+Path,false); + return true; + }, + IcoPath = "Images/folder.png" } } }).ToList(); } + static string ResolveShortcut(string filePath) + { + // IWshRuntimeLibrary is in the COM library "Windows Script Host Object Model" + IWshRuntimeLibrary.WshShell shell = new IWshRuntimeLibrary.WshShell(); + IWshRuntimeLibrary.IWshShortcut shortcut = (IWshRuntimeLibrary.IWshShortcut)shell.CreateShortcut(filePath); + return shortcut.TargetPath; + } + private bool MatchProgram(Program program, FuzzyMatcher matcher) { if ((program.Score = matcher.Evaluate(program.Title).Score) > 0) return true; diff --git a/Plugins/Wox.Plugin.Program/Wox.Plugin.Program.csproj b/Plugins/Wox.Plugin.Program/Wox.Plugin.Program.csproj index 324b0fb103..a517e1407e 100644 --- a/Plugins/Wox.Plugin.Program/Wox.Plugin.Program.csproj +++ b/Plugins/Wox.Plugin.Program/Wox.Plugin.Program.csproj @@ -121,7 +121,17 @@ Wox.Plugin - + + + {F935DC20-1CF0-11D0-ADB9-00C04FD58A0B} + 1 + 0 + 0 + tlbimp + False + True + +