Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide existing items in Context Menu #73

Open
wmjordan opened this issue Oct 27, 2020 · 4 comments
Open

Hide existing items in Context Menu #73

wmjordan opened this issue Oct 27, 2020 · 4 comments
Labels
enhancement New feature or request

Comments

@wmjordan
Copy link

Instead of adding items, is it possible to hide existing items in the Context Menu?

For instance, the following code will instruct ShellAnything to hide the existing "Properties" menu item.

<hide title="Properties" />

A thing has similar functionality is a close source software moo0 right clicker which does not use XML configuration files but provides user interfaces to do so.

@wmjordan wmjordan added the enhancement New feature or request label Oct 27, 2020
@end2endzone
Copy link
Owner

Hi.

No, ShellAnything can not be used to remove existing items on the context menu.

I do not plan to implement this functionality because this is not a trivial task:

  • In theory, a Shell Extension may (I have never tried) be able to hide menu item that was added by a previously processed Shell Extension but it will be unable to hide the menu items that is are to be created by the following Shell Extensions.
  • Shell Extensions are loaded and processed by Windows and as far as I know, there is no way to specify that ShellAnything is loaded and processed as the last one so that it could hide any existing menu item. (I have not explored this functionality that much. If I am wrong, feel free to let me know).

I am not saying it cannot be done, you obviously mentioned moo0 right clicker which I did not know about. I also remember printing all the menu items (including the ones that are not created by ShellAnything) in my debug builds.

Regarding your example, since the menu item is not a third party item, there could be registry settings that would remove the specific menu items. I have never searched for it. I doubt there would be a registry setting that would remove "Properties" but I guess you used this example as a "menu item that every computer has".

Regarding custom menu items (for example "Open with application XXX" and "Edit with application XXX"), then you need to look if application XXX has the ability to disable a specific menu. If not, then you may be able to disable ALL menu items of application XXX by unregistering its Shell Extension. You can also take a look a #57 for details on how to disable a Shell Extension.

I am open to suggestion and feature requests about ShellAnything. If you ever find documentation on how to properly implement such a functionality, I would gladly appreciate the help.

@wmjordan
Copy link
Author

Thank you very much for keeping this issue opened.

It is really not a trivia task.

I'd been using the moo0 right clicker for quite a few years and occasionally I observed that some applications got hung and consume a lot of CPU resources. I made a mini dump from a recently hung application and analyzed it with windbg, suspected that the right clicker could be the cause of the hanging. -- it is really so hard to write a thing like that.

I observed the behavior of the right clicker. It implemented the customized context menu by replacing the existing context menu in Explorer with its owner drawn one. A bonus of this implementation is that geekers can customize not only menu items, but also the appearance of the context menu as well.

And another application which had done the similar thing was Mmm (I could not find the official web site anymore, hence this link to a blog, sorry), while it was in the Windows XP time, almost decades ago. This little application had another useful function to move rarely used menu items into a sub menu (by default named Rarely used), which was more convenient when we were to hide some items but sometimes still wanted to access them.

The common thing is that Both right clicker and Mmm replaces the builtin context menu with their owner drawn one. Maybe it is the way to go.

I am sorry that I know so little about shell programming that I can not provide more useful information to you.

Maybe you can give the right clicker a try and use a tool named Inspect executable file provided by Process Hacker to analyze the imported DLL functions from within the main DLL that the right clicker uses, which locates in "%systemroot%\System32\ShellExtBridge\ShellExtBridge119.dll". Would it be possible to figure out what API functions we shall use from the DLL imports to implement this featuer?

shot

@end2endzone
Copy link
Owner

Hi.
Thank you for providing a better avenue of investigation.

I have no experience with owner drawn menus but there seems to be multiple examples or references on internet:

However, I feel this might require a huge time investment in order to get this feature working and I already have other priorities and plans in the pipeline for ShellAnything right now (like implementing plugin support which is defined in issue number 50).

I leave the issue open when someone have the time and the skills to implement such a feature.

@wmjordan
Copy link
Author

wmjordan commented Oct 31, 2020

Thank you for the information.

I actually don't know whether the owner drawn menu is the essential part of the implementation or not.
I just made an assumption since both Mmm+ and Moo0 Right Clicker happen to appear so.

Obstacles to implementing this feature are:

  1. Suppressing the default context menu and replace it with your own. I observed there were imports to DestroyMenu, DeleteMenu from user32.dll in the DLL from Right Clicker(plz look at the screenshot in my prior comment)--could those functions have something to do with this feature?
  2. Maintaining menu hierarchy, for example, WinRAR can create its context menu item with sub items.
  3. Handling graphical menu items, for instance SageThumbs, which places a small preview image into the context menu when you right click an image file in Windows Explorer.

If we are to hide existing items in the context menu, we have to preserve those special items.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants