srwi / EverythingToolbar

Everything integration for the Windows taskbar.
Other
9.49k stars 412 forks source link

Open Windows context menu using Shift+RClick #353

Open kwyntes opened 1 year ago

kwyntes commented 1 year ago

Preflight Checklist

Problem Description

It's already tedious enough not being able to use just the keyboard to perform actions, and having to click through two menus just to edit a script file (since simply opening it will execute it) is even worse.

Right now to access the Windows context menu, for example to "Edit with Notepad++", one has to first right click on the search results, then click show more options, then click the desired option.

Proposed Solution

Shift+right click (or a different shortcut if shift+right click would cause issues for whatever reason) would skip the context menu implemented by this app and go straight into the Windows context menu.

Alternatives Considered

Another solution I thought of is to implement the option to add custom shortcuts to trigger custom actions, which would eliminate the need for context menus entirely. I figured this would be a lot more complicated to implement however, so I propose this simple solution instead.

Additional Information

No response

kwyntes commented 1 year ago

Looking at the code it seems like this feature could be added by simply adding these two lines in EverythingToolbar/Controls/SearchResultsView.xaml.cs:

        private void OnContextMenuOpened(object sender, RoutedEventArgs e)
        {
+           if (Keyboard.Modifiers == ModifierKeys.Shift) {
+               return SelectedItem?.ShowWindowsContextMenu();
+           }
+
            ContextMenu cm = sender as ContextMenu;
            MenuItem mi = cm.Items[2] as MenuItem;

            string[] extensions = { ".exe", ".bat", ".cmd" };
            bool isExecutable = (bool)SelectedItem?.IsFile && extensions.Any(ext => SelectedItem.FullPathAndFileName.EndsWith(ext));

            if (isExecutable)
                mi.Visibility = Visibility.Visible;
            else
                mi.Visibility = Visibility.Collapsed;
        }

I don't know how to setup the development environment to test this out myself, but since it is such a simple change I'm fairly confident that this would work.

srwi commented 1 year ago

Thank you for your effort!

Interestingly SelectedItem does not get updated when holding down the Shift or Control modifiers, so it will open the system context menu for the wrong search result. Using Alt causes the context menu to close right after opening. I think using Shift would be the correct way to do it though.

Currently I'm a little busy, but I'll look into it eventually. In the meantime, if you want to have a shot at it, feel free to have a look at the build instructions in the readme!