Added open in folder to the program plugin.

This commit is contained in:
Boelensman1
2015-01-30 02:18:18 +01:00
parent a112c6d9ee
commit 4672628ee2
2 changed files with 44 additions and 1 deletions

View File

@@ -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;