-
Notifications
You must be signed in to change notification settings - Fork 160
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
Compatible with Win11 new context menu (suggestion) #671
Comments
It will be great if MediaInfo can integrate with the new Windows 11 context menu like other apps such as Mp3tag. Looks like it can be implemented by non-Store apps too according to this post:
|
We don't use (yet) Win11 I didn't remark that MediaInfo is hidden in the "Show more options" part :(. |
Switched to Win11 no context menu item please fix and could you add a dark mode and I am using the installable version not store app version. Thankyou. |
bump integration into the new win11 context menu would be really great! if someone might me able to point into the right direction, i could try implementing it myself ^^ |
Main issue is this topic ;-). |
microsoft seems to have a sample project for win11 context menu stuff |
I don't have experience with sparse packages, Win11 context menu or MediaInfo codebase but from my understanding, the following is needed for an application that is not packaged as a MSIX.
Microsoft resources: For more examples, maybe can look at NanaZip although this one is a MSIX packaged app but it should be using IExplorerCommand. Can also look at Visual Studio Code or Notepad++ which are unpackaged applications that use sparse manifests to add a Edit/Open with command on Win11 menu although I'm not sure if these two work properly. |
One more resource that might help: https://community.mp3tag.de/t/context-menu-on-windows-11/54629/7 |
@JeromeMartinez I have figured it out. It is possible. I made a PoC attached below. Tested to be working on a VM and it even works for folders. It consists of two main things:
WARNING: only do the following on a test machine / VM. I cannot guarantee whether your Windows installation will be messed up or not.
There are still things to do if this were to be integrated with official MediaInfo distribution.
This is a minimal, very basic implementation. If you look at https://github.com/notepad-plus-plus/nppShell which is the current implementation used by Notepad++, it is very complex. I do not know how complex MediaInfo's implementation needs to be. For more info about how it works and how to implement, please refer to my 2 posts above. |
I am not going to work on this anymore since I am not good at writing shell extensions and I also cannot do anything with the other parts that require changes to MediaInfo's existing context menu, build system, packaging, installer, signing etc. So MediaInfo's members or someone else should take over from here. You can ask me questions about the PoC though. |
@cjee21 thank you! We'll use it as a base when we have time for working on it. |
Note that it is possible to make multiple files open in a single instance of MediaInfo instead of opening multiple windows when multiple files are selected before invoking the explorer context menu with some code changes if this is desirable. |
This (a single instance) is actually the expected behavior. |
Outdated:
Now implemented in updated PoC. See below. |
Here is an updated version of the PoC. Changes:
Here is a video of it in action on a real (not VM) Windows 11 PC. It shows opening a folder, opening multiple files and opening a single file. As a bonus, it also shows the WebView2 PR in action towards the end. demo.mp4How it works is the DLL will be loaded and invoked by Windows File Explorer when the context menu entry is clicked. The DLL then parses the selected items and executes MediaInfo.exe, passing the item paths as command line arguments. Therefore, this should work on the Qt version as well. A reminder that this PoC contains a lot of copy-pasted codes and even AI generated codes that are not thoroughly checked by me. |
Thank you a lot, it helps to have a PoC.
We could add the new DLL entry point to our "mouse over" DLL, as we already have a DLL loaded by MediaInfo (when the option is active).
We'll peek what is really useful and understood by us. |
From my understanding (I'm not an expert in this), this new context menu DLL can also be used for Windows 7 and newer. So maybe can completely replace the current context menu implementation and gain the advantage of opening multi files in a single instance for all Windows versions. However, seems that to achieve that, we need two different methods of registering the DLL as starting with some version of Windows 10 and later, it is done by registering a signed sparse package (this method is needed to appear on Windows 11 new menu) while older Windows use traditional DLL registration. The Notepad++ project's latest implementation seems to be doing this. This PoC is not based on their latest implementation. |
Since it seems there is no much progress on this issue and there are currently many active PRs on the GUI side (don't want to make more changes there and risk many merge conflicts), I spent some time on this issue and brought the previous PoC into a deploy-able state for testing and as more proof of concept of what is possible. I've put it here: At the moment, the new context menu shell extension is only implemented for Windows 11. The shell extensions settings in MediaInfo preferences is not yet updated to handle this new shell extension so toggling that on Windows 11 may have unintended effects. |
Sorry about the delay in handling your PR (which are very appreciated), it is a matter of agenda issue on our side, I hope to handle them soon.
thank you!
this is part of the reasons we are cautious, it can be messy for lot of people if we don't implement it well. |
Here is a video of the current state of the branch linked above. It shows from before installation to after uninstallation on a physical Windows 11 build 22631 PC. Recording.2024-09-22.mp4The README of the branch has been updated with mode details too. |
thank you! |
Thank you for the update.
Hum, I would prefer to control the integration here because some people may complain about the extension, but not a big deal right now.
Great! Related in the readme:
do you mean that this method is also available for Win7-Win10?
Ho, wasn't it the case with the current version? I didn't check much, i need to.
This is great because it is same for me, I prefer to avoid big package.
I am super late but don't forget all the work you did, I want to integrate it, I just have to finish some work before it but again, it is in my mind that I need to review then merge that. |
Should be possible since the Store version of Mp3tag can toggle the context menu in settings. I think it is done by writing code in the shell extension DLL which checks whether it should show or not when File Explorer triggers it. Perhaps it is the GetState function. It should not be done by uninstalling and installing the sparse package as done by some apps. At the moment, if someone complains, they can disable it by manually uninstalling the sparse package using PowerShell since we are not using the package for any other features at the moment. It will stay disabled until a new MediaInfo update re-enables it.
According to Microsoft, IExplorerCommand extends back to Windows 7 (maybe even Vista). So I think it is possible to use the same DLL shell extension for context menu in all Windows versions. The advantage would be consistency in how multiple files are opened in a single instance and also ability to remove the registry handling codes for the old implementation. However, to register it, only WIndows 10 build 19000 onwards supports the sparse package method. On older versions, probably need to use the traditional registry/regserver method which I do not know how.
Now MediaInfo is an unpackaged app so it does not have an app identity (Package name is blank). With the sparse package, although it is still unpackaged, it is now a little like a packaged Store app. The taskbar icon is now handled like a packaged app and it has app/package identity which grants access to the new Windows 11 context menu, the Windows share sheet, the Windows App SDK notifications API and more. The taskbar icon is displayed properly now. I am comparing to other apps like Google's Nearby Share which has missing icons when launched from context menu as the sparse package / app identity is not implemented properly. It does not have package name in task manager also. Same with Notepad++ and VSCode which resorted to putting it in a subfolder to solve the missing icon and thus the main app does not have package identity. The correct way is to put the icon assets in the app folder. I think many apps package the icons in the MSIX, that's why theirs is large. A sparse package is supposed to be sparse. All resources that it references are supposed to be in the 'external location' that we declare during install and not in the package itself.
The priority is PR916 which contains minor changes for bug fixes. This should be merge-able without issues and any other changes. I noticed there are also some security-related MediaInfoLib issues such as overflow and crashing which I think should be given priority too. This Windows 11 context menu stuff I will only make a PR if you are okay with how it is done and if you want me to make a PR since it is a larger change than the other PRs and contains code based on other repositories' code. I have checked through every line of the code and it is also modified at this stage so technically it should be okay (I trust it enough to be running it on my main PC) but I am not sure about licensing (some code is based on GPL and MIT code but I have already modified them). I may also have to explain more / work it though with you because it requires changes to the build system/script to build and sign the new things. I am also now using C++Builder 12 and MSVC 2022 so if the other two PRs and this context menu does not build with existing build farm, then either the build farm is upgraded or changes have to be made. I understand there are likely more important things on MediaInfoLib side that you are currently busy with. I will wait patiently. Just give me a mention when you want to start working on this and the other two PRs (they likely need rebase/changes and changes to build farm) and I'll be here. PR916 should be merge-able as it is without needing me. |
New video Recording.2024-10-05.mp4Made some minor changes to the branch. The README has been updated too. The most noticeable change is that now there is no PowerShell window pop-up during uninstall. |
Great, thank you! |
FYI I have re-based the branch to latest master. Now it only contains Windows 11 context menu stuff. I have also re-written the shell extension DLL using C++/WinRT, tidy up the codes and updated the README. It still works the same. |
Some updates on the branch.
|
Was it also the case in previous version? by the way:
Is also a strong limitation, lot of users disable it. Is it also the case with npp?
:(. |
I don't know. I don't use npp. But if you look at their implementation, very very complicated and not bug-free. VSCode seems to have issue with installation too since they have not rolled it out to stable channel. Right now the new installation method for MediaInfo is inspired by a commit from npp that is not merged yet and is different than what VSCode does but results in a provisioned package similar to Adobe Acrobat (they are using it for share sheet, not context menu). I have put command to refresh File Explorer after provisioning but seems it refreshed before the package is registered. It will appear if a refresh is triggered by something else (the old shell extension code in MediaInfo seems to do the trick) or File Explorer is restarted (like a re-login).
Mp3tag can be disabled. Microsoft's built-in apps doesn't seem to be able to disable. This can be done later on, Probably need to use registry (The rough idea is to make MediaInfo write a registry value when disabled in Preferences, then DLL checks registry and return
We don't need app identity at the moment anyway since not using things like share sheet or notifications API. The only thing is no package name appear in task manager or process explorer. At the moment, after this most recent update, it is stable on my system. The only thing I am concerned is the installation/updating part especially on systems with different configurations (need others to test to find out). The context menu itself I am quite confident of the stability. |
As you are there, is it possible to have app identity for MI program and a second one for the menu? |
I don't think it is a good idea to do this just to get something to appear in task manager. The sparse package seems to have some strange behaviour/bugs in Windows. The size of the installation will also increase with more files to have two. If want package identity and eliminate installation/uninstallation issues, better to package the whole app as MSIX than to use sparse package in my opinion. If it is possible to package whole app as MSIX, there should be no issues with the context menu like Mp3tag store version or Microsoft's pre-installed apps. Adobe Acrobat, Npp, VSCode, Google Nearby Share etc. all implement sparse package differently and none seems to have identity on the main app. |
btw if a file has a path longer than 260 characters, only the new context menu and file open dialog can open it in MediaInfo. Drag/drop to window or drag/drop to MediaInfo shortcut does not work. Opening the folder containing the file via new context menu or via folder open dialog results in an empty file entry in MediaInfo. |
I guess that there is a way to get the long path, but yet another code to add after having found the right API :(. |
When it opens properly via new context menu or file open dialog, the path starts with MPC-BE recently added long path support: https://github.com/Aleksoid1978/MPC-BE/blob/7979fc78d63f52f883ef6054fe7db14f8cbce854/docs/Changelog.txt#L23 Edit: I think I get the idea. Opening with |
I tested this again. After installing, without launching MediaInfo or doing anything else, File Explorer seems to refresh itself and the context menu entry appears within less than a minute. I have questions after looking through the installer script:
Update: Made changes to installer script in the branch. Now the new context menu entry appears right after install for the user who installs (even before the installer window is closed). Now the uninstaller also no longer has a 3 second delay and is super fast to complete. Also used absolute path when calling regsvr32 to prevent any possibility of hijacking (no idea how Exec function searches for an executable but we won't want any possibility of something like this). Update 2:
The branch is now updated with feature to disable the context menu entry. Just set |
Updated branch again. Now can enable and disable the new context menu via GUI Preferences. It is implemented without touching the old code. It may be possible to integrate it better with the old code or use the DLL for all Windows versions by modifying the old code but I will not be doing that as I did not take time to understand the old registry handling codes that are long. Here is the new video: Recording.2024-10-16.mp4 |
Great! |
Hmm... I managed to package the MediaInfo Qt version as a MSIX, everything including context menu is working but the same strange behaviour is present. So it is not caused by sparse package. I wonder what's the cause. If we can solve this then we can have package identity for the VCL one too and implement everything the ideal as supposed to be way. strange behaviour = When MediaInfo is started from anywhere other than the context menu and left open, right-clicking a file will fail to load the context menu entries and cause MediaInfo to force close without errors. |
Definitely strange and no idea about the source of that :(. |
Good news! Finally I solved this strange issue. Since it does not happen to my other installed apps, I digged the manifest file of Mp3Tag that is installed from the Store on my PC. The solution to this strange issue? Replace Probably a Windows bug. The top one is supposed to be new format for newer Windows version if I understand correctly. So I will re-change and clean-up the Win 11 context menu stuff again to do it the ideal way and will update the branch. Will do it when free, likely not today. PS @JeromeMartinez If you want the packaged, installable Qt version of MediaInfo for Windows to see/test it, let me know, I can give you the MSIX. |
Great!
Would you mind to put the source code in a PR? So you don't have to maintain it in a branch. |
I can post the manifest but I built the MSIX manually. Requires putting required binaries and assets in the correct folder and running the packaging commands manually. What about the Windows 11 context menu for VCL one? Should I make a PR for that yet? It's a huge change with many new project and source files that I do not know if I named/put them in the places you like. |
Would you mind to do a
I checked your branch and I am fine with the file names you use, I don't want to be picky there as you already did a huge work there. If I want to change stuff, I will do it later on my own time. My concern is more about stability, pre-Win11 machines must see no difference, and Win11 users must be able to activate/deactivate it in the GUI as they use to do for the current integration, it must be also portable i.e. can be fully managed without the installer or uninstaller (we have ZIP files). |
Stupid question: is there any chance that this Win11 integration is also available with the Windows Store (UWP version, yet another UI for MediaInfo...) version? It seems that this is not easy to have Explorer integration with Windows Store security, I just ask in case you know... |
I should write a .cmd for it when free else I may forget how to do it in the future. Just doing a one shot build for now. Still not sure if I want to maintain and use a self-built Qt version instead of the official one.
So far it has been stable on VCL and Qt for installed versions on Windows 11. I didn't test on older Windows because all PCs here are Windows 11 and my VM was deleted. Since I added version checks at many places, it should be okay. I will leave it up to your team to integrate better / clean-up the old one. The ultimate test is to build it on your build farm and test to make sure it is build-able and works. It has to be tested because it requires signing and has to work on non-development PCs when signed using your production certificate. For ZIP files, I believe shell integrations (including existing one) should not be active on those as it risks leaving things behind (like registry entries) when folder is deleted/moved. For Windows 11 context menu, it should be disabled when running portable. It requires installing packages which makes it non-portable by design. The activate and deactivate of context menu entry from GUI is already working well on both VCL and Qt for quite some time now.
Should be possible for store apps. I have the modern context menu for things like Notepad, Mp3Tag, Clipchamp... all these apps are from Store and updated by Store. Mp3Tag is Win32 but the other Microsoft apps I am not sure is UWP or Win32. They look like built with WinUI3 with all the new Mica materials. It should be possible to distribute the Qt version on the Store as well along with the context menu. If that happens I may switch to using that. 😆 Long ago, I wanted to get MediaInfo from Store but found out lack of context menu which is a deal-breaker. PS Screenshot on official website and Store should probably be updated. They no longer accurately reflect the current look (especially the Store one). New users might be surprised. |
Updated the branch and tested both VCL and Qt. Context menu working fine including enabling/disabling via GUI. No more strange thing happening and MediaInfo runs with package name in Task Manager / Process Explorer. Taskbar icon appears properly too. I will do the following another day:
|
I will test on Win7 32-bit, Win7 64-bit & Win10 64-bit.
Please keep it i.e. no specific test installed vs ZIP. Users like to have it with a ZIP, their business if they delete the directory.
Clearly... and when we created the UWP app, Win32 apps were forbidden... Now that Win32 app are permitted, we may just drop the UWP app, I don't know...
Right, something we need to do. |
You mean that all is back as in your initial tests, and it is exactly as you expected, no more drawback? Great! |
dev snapshot from it for my curiosity just for your info. |
Compatible with Windows11 new context menu
The text was updated successfully, but these errors were encountered: