From 4672628ee2c0b8aee7b3bef85a4b4d858453a963 Mon Sep 17 00:00:00 2001 From: Boelensman1 Date: Fri, 30 Jan 2015 02:18:18 +0100 Subject: [PATCH 1/2] Added open in folder to the program plugin. --- Plugins/Wox.Plugin.Program/Programs.cs | 33 +++++++++++++++++++ .../Wox.Plugin.Program.csproj | 12 ++++++- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/Plugins/Wox.Plugin.Program/Programs.cs b/Plugins/Wox.Plugin.Program/Programs.cs index 31f8d9b53a..07d1c73f07 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,43 @@ namespace Wox.Plugin.Program return true; }, IcoPath = "Images/cmd.png" + }, + new Result() + { + Title = "Open Containing Folder", + Action = _ => + { + context.API.HideApp(); + context.API.ShellRun(c.ExecutePath,true); + + 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,true); + 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 + + From b30f3d6b8ff1e17c6bfd21dd77711d760007d48c Mon Sep 17 00:00:00 2001 From: Boelensman1 Date: Fri, 30 Jan 2015 15:54:02 +0100 Subject: [PATCH 2/2] Forgot to remove some lines. No longer opening explorer with admin rights. --- Plugins/Wox.Plugin.Program/Programs.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Plugins/Wox.Plugin.Program/Programs.cs b/Plugins/Wox.Plugin.Program/Programs.cs index 07d1c73f07..7028848b83 100644 --- a/Plugins/Wox.Plugin.Program/Programs.cs +++ b/Plugins/Wox.Plugin.Program/Programs.cs @@ -62,9 +62,6 @@ namespace Wox.Plugin.Program Title = "Open Containing Folder", Action = _ => { - context.API.HideApp(); - context.API.ShellRun(c.ExecutePath,true); - context.API.HideApp(); String Path=c.ExecutePath; //check if shortcut @@ -76,7 +73,7 @@ namespace Wox.Plugin.Program //get parent folder Path=System.IO.Directory.GetParent(Path).FullName; //open the folder - context.API.ShellRun("explorer.exe "+Path,true); + context.API.ShellRun("explorer.exe "+Path,false); return true; }, IcoPath = "Images/folder.png"