Skip to content

Commit 1327250

Browse files
committed
Add "Open With" option to file context menu
Signed-off-by: Florian Grabmeier <[email protected]>
1 parent 03bf15f commit 1327250

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ public List<Result> LoadContextMenus(Result selectedResult)
5252
}
5353
}
5454

55+
if (record.Type == ResultType.File)
56+
{
57+
contextMenus.Add(CreateOpenWithMenu(record));
58+
}
59+
5560
contextMenus.Add(CreateOpenContainingFolderResult(record));
5661

5762
if (record.WindowsIndexed)
@@ -434,6 +439,21 @@ private Result CreateOpenWindowsIndexingOptions()
434439
};
435440
}
436441

442+
private Result CreateOpenWithMenu(SearchResult record)
443+
{
444+
return new Result
445+
{
446+
Title = Context.API.GetTranslation("plugin_explorer_openwith"),
447+
SubTitle = Context.API.GetTranslation("plugin_explorer_openwith_subtitle"),
448+
Action = _ =>
449+
{
450+
Process.Start("rundll32.exe", $"{Path.Combine(Environment.SystemDirectory, "shell32.dll")},OpenAs_RunDLL {record.FullPath}");
451+
return true;
452+
},
453+
IcoPath = Constants.ShowContextMenuImagePath
454+
};
455+
}
456+
437457
private void LogException(string message, Exception e)
438458
{
439459
Log.Exception($"|Flow.Launcher.Plugin.Folder.ContextMenu|{message}", e);

Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,9 @@
102102
<system:String x:Key="plugin_explorer_remove_from_quickaccess_title">Remove from Quick Access</system:String>
103103
<system:String x:Key="plugin_explorer_remove_from_quickaccess_subtitle">Remove current item from Quick Access</system:String>
104104
<system:String x:Key="plugin_explorer_show_contextmenu_title">Show Windows Context Menu</system:String>
105-
105+
<system:String x:Key="plugin_explorer_openwith">Open With</system:String>
106+
<system:String x:Key="plugin_explorer_openwith_subtitle">Select a program to open with</system:String>
107+
106108
<!-- Special Results-->
107109
<system:String x:Key="plugin_explorer_diskfreespace">{0} free of {1}</system:String>
108110
<system:String x:Key="plugin_explorer_openresultfolder">Open in Default File Manager</system:String>

0 commit comments

Comments
 (0)