Jump to content

Where to start with Context Menu for Windows 11


Go to solution Solved by WildByDesign,

Recommended Posts

Posted

I've been stuck on this topic for a while now. I'm talking specifically about the modern context menu of windows 11 meaning tweaking registry doesn't work outside of "Open with".

Notepad++ was my first helping hand so I've looked into the nppshell.dll on github but I have no experience with that language and even with AI I couldn't modify the file even though it was "guiding me through the process".

What I'm trying to achieve is create a single menu option with a submenu that will have various other options depending on the extension. I'm not looking for someone to write me the code just point me in the right direction.

Posted (edited)

Maybe something like this?

https://learn.microsoft.com/en-us/windows/win32/shell/context-menu-handlers

Edit:

And in SMF I use something like this for optional shell integration.

RegWrite("HKEY_CURRENT_USER\Software\Classes\Directory\shell\Search with SMF", "Icon", "REG_EXPAND_SZ", """" & @ScriptFullPath & """")
    RegWrite("HKEY_CURRENT_USER\Software\Classes\Directory\shell\Search with SMF\command", "", "REG_SZ", """" & @ScriptFullPath & """ ""%l""")

    RegWrite("HKEY_CURRENT_USER\Software\Classes\Drive\shell\Search with SMF", "Icon", "REG_EXPAND_SZ", """" & @ScriptFullPath & """")
    RegWrite("HKEY_CURRENT_USER\Software\Classes\Drive\shell\Search with SMF\command", "", "REG_SZ", """" & @ScriptFullPath & """ ""%l""")

    RegWrite("HKEY_CURRENT_USER\Software\Classes\Directory\shell\Search with SMF for duplicate files", "Icon", "REG_EXPAND_SZ", """" & @ScriptFullPath & """")
    RegWrite("HKEY_CURRENT_USER\Software\Classes\Directory\shell\Search with SMF for duplicate files\command", "", "REG_SZ", """" & @ScriptFullPath & """ ""%l -duplicates""")

    RegWrite("HKEY_CURRENT_USER\Software\Classes\Drive\shell\Search with SMF for duplicate files", "Icon", "REG_EXPAND_SZ", """" & @ScriptFullPath & """")
    RegWrite("HKEY_CURRENT_USER\Software\Classes\Drive\shell\Search with SMF for duplicate files\command", "", "REG_SZ", """" & @ScriptFullPath & """ ""%l -duplicates""")

and this in ICU for integration into desktop context menu

RegWrite("HKEY_CURRENT_USER\Software\Classes\DesktopBackground\shell\ICU_ContextMenu_Anchor", "MUIVerb", "REG_SZ", "ICU")
            RegWrite("HKEY_CURRENT_USER\Software\Classes\DesktopBackground\shell\ICU_ContextMenu_Anchor", "Position", "REG_SZ", "Bottom")
            RegWrite("HKEY_CURRENT_USER\Software\Classes\DesktopBackground\shell\ICU_ContextMenu_Anchor", "Icon", "REG_EXPAND_SZ", @ScriptFullPath & ",0")
            RegWrite("HKEY_CURRENT_USER\Software\Classes\DesktopBackground\shell\ICU_ContextMenu_Anchor", "ExtendedSubCommandsKey", "REG_SZ", "DesktopBackground\ContextMenus\ICU")

            RegWrite("HKEY_CURRENT_USER\Software\Classes\DesktopBackground\ContextMenus\ICU\Shell\001_ICU", "Icon", "REG_EXPAND_SZ", "shell32.dll,-22")
            RegWrite("HKEY_CURRENT_USER\Software\Classes\DesktopBackground\ContextMenus\ICU\Shell\001_ICU", "MUIVerb", "REG_SZ", "Open ICU Settings")
            RegWrite("HKEY_CURRENT_USER\Software\Classes\DesktopBackground\ContextMenus\ICU\Shell\001_ICU\command", "", "REG_EXPAND_SZ", @ScriptFullPath)

            RegWrite("HKEY_CURRENT_USER\Software\Classes\DesktopBackground\ContextMenus\ICU\Shell\002_ICU", "Icon", "REG_EXPAND_SZ", "shell32.dll,-7")
            RegWrite("HKEY_CURRENT_USER\Software\Classes\DesktopBackground\ContextMenus\ICU\Shell\002_ICU", "MUIVerb", "REG_SZ", "Save Desktop Layout")
            RegWrite("HKEY_CURRENT_USER\Software\Classes\DesktopBackground\ContextMenus\ICU\Shell\002_ICU", "CommandFlags", "REG_DWORD", 0x040) ; ECF_SEPARATORAFTER
            RegWrite("HKEY_CURRENT_USER\Software\Classes\DesktopBackground\ContextMenus\ICU\Shell\002_ICU\command", "", "REG_EXPAND_SZ", @ScriptFullPath & " save")

 

Edited by KaFu
Posted

Thanks for the reply @KaFu however this doesn't work in the modern windows 11 context menu.

A solution like this is what I'm looking for but through AutoIt. I don't mind even using that through DllCall function if only I understood what data to pass.

Posted

I'm aware that it can change that's why I brought up the notepad++ example. From what I've read it requires a fairly extensive knowledge of C as it's done in a completely different way.

With registry, you can only add custom option into the "Open with" menu which is a workaround I might settle for now. Perhaps I'll simply add an option with registry there and then once selected "Open with My program" I'll reopen the context menu at old position and MyProgram will create an identical looking submenu to sort of act like a native context submenu but that will definitely introduce delay since opening context menu on win11 takes a while.

And no, I'm not looking into bringing back the old context menu as eventually that will be gone and it doesn't fit well with the modern look of windows 11.

  • Solution
Posted

The last time that I looked into it, you had to pay a hefty price for a digital signature cert to sign your binaries with. Without the digital signature, the sparse package identity stuff would be invalid.

It might be possible to have a self-created certificate installed locally but I am not 100% sure if that would work or not.

In the old days, context menus would get filled up with so much garbage from so many apps. So I guess this newer method will prevent much of that. But unfortunately it also makes it more difficult and costly.

Posted

@WildByDesign I did run into someone already mentioning sparse package manager and having to register the application along with other things that I didn't understand as it was C language specific.

Then for now I'll stick with my workaround until I learn a thing or two about certificates and whatnot.

Thank you for that.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...