From 1327250a6fc29375965c903dd576309586215323 Mon Sep 17 00:00:00 2001 From: Florian Grabmeier Date: Tue, 16 Jan 2024 22:55:25 +0100 Subject: [PATCH] Add "Open With" option to file context menu Signed-off-by: Florian Grabmeier --- .../ContextMenu.cs | 20 +++++++++++++++++++ .../Languages/en.xaml | 4 +++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs b/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs index b4924a0fc..96a4af09c 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs @@ -52,6 +52,11 @@ namespace Flow.Launcher.Plugin.Explorer } } + if (record.Type == ResultType.File) + { + contextMenus.Add(CreateOpenWithMenu(record)); + } + contextMenus.Add(CreateOpenContainingFolderResult(record)); if (record.WindowsIndexed) @@ -434,6 +439,21 @@ namespace Flow.Launcher.Plugin.Explorer }; } + private Result CreateOpenWithMenu(SearchResult record) + { + return new Result + { + Title = Context.API.GetTranslation("plugin_explorer_openwith"), + SubTitle = Context.API.GetTranslation("plugin_explorer_openwith_subtitle"), + Action = _ => + { + Process.Start("rundll32.exe", $"{Path.Combine(Environment.SystemDirectory, "shell32.dll")},OpenAs_RunDLL {record.FullPath}"); + return true; + }, + IcoPath = Constants.ShowContextMenuImagePath + }; + } + private void LogException(string message, Exception e) { Log.Exception($"|Flow.Launcher.Plugin.Folder.ContextMenu|{message}", e); diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml index d5352ef1e..f2491d928 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml @@ -102,7 +102,9 @@ Remove from Quick Access Remove current item from Quick Access Show Windows Context Menu - + Open With + Select a program to open with + {0} free of {1} Open in Default File Manager