Git Product home page Git Product logo

shell-x's Introduction

Shell-X

paypal

Dynamic customizable file context menu solution for Windows. Allows creating context menus of any complexity without the need to compile COM shell extensions. The solution is based on the same concept as Windows Explorer native "Send to" context menu.

Overview

In Windows Explorer context menus are an extremely important part of the User Experience (UX). Just a single right-click on the file allows a convenient access to the file type specific operations.

Unfortunately creation and customization context menus were always a pain point. The problem is that Windows implements explorer context menus as so called Shell Extensions. They are a heavy weight COM servers that is not trivial to implement. And what is even more important they are components that must be rebuild/recompiled every time user wants to change the menu structure or the associated menu action. And this in turn dramatically affects the user adoption of context menus as an operating system feature.

Interestingly enough Windows has introduces an alternative light way for managing very specific context menu - "Send to".

image

The customisation of the "Send to" is dead simple. User simply goes to the special folder and creates there shortcut(s) to the desired application. Then at runtime the shortcut name will become the content menu item. And shortcut itself will be invoked (with the selected file path passed as an argument) when user selects this menu item.

image

This means that creation and customization of the "Send to" context menu is a simple file creation/editing activity that does not even require user to be an admin (elevated).

Shell-X applies the same simplified approach but extends it by allowing creation of any context menu for any file type.

Below are the some of Shell-X features that extend Windows "Send to" approach:

  • Support for complex nested context menus.
  • Support for console and windows menu actions.
  • Support for both batch files and PowerShell scripts as an action associated with a menu item.
  • Support for custom icons in the menu items.
  • The action definition is no longer a shortcut but a batch file so a menu action can have multiple steps.
  • Definitive menu items order thanks to the use of the sortable prefixes in the file names.
  • Individual context menu definitions for file types based on the file extension.

Note, that intencive use of icons may lead to the memory exhaustion.. This is Windows Explorer bug / design flaw. Thus don't overuse this feature. You can read more about this in this therad.

Installation

With Chocolatey

Install package Shell-X:

choco install shell-x

Manually

  • Download the release package and unzip its content in any location.
  • Execute the following two commands in the command prompt
    shell-x -r
    shell-x -init
    

To uninstall just execute:

shell-x -unregister

Note, the explorer may lock the extension file so you may need to restart it before you can delete the file.

Configuration

After the installation the sample context menu (as described in the next section) will be created. Do modify and extend it as you wish by creating properly name batch files in the configuration folder as described in the next section.

You can open configuration folder any time by executing the open command in command prompt:

shell-x -open

There is also an option (v1.4.0+) for testing the configuration outside of the Windows explorer

shell-x -test [path]

It is helpful for refining the mapping of the configuration to the selected item (path) actions.

image

How it works

Shell-X maintains a global directory, which file tree structure defines the complex context menu tree to be displayed at runtime on right click.

The root folders are named according the file extension that the context menu is for. Thus the folder txt contains context menu definition for all text files, the dll folder is for all DLLs. And there are two special folder names:

  • [any] that defines the context menu for any selected file or a folder.
  • [folder] that defines the context menu for any selected folder.
  • [file] that defines the context menu for any selected file.

Below is the example of the configuration for two separate context menus for text files and for any file.

image

And this is how the menus look at runtime.

image

In the example above the context menu for txt files has a complex structure containing sub-menus for opening selected file with Notepad and other file handling operations.

The content of 00.Notepad.cmd file is an ordinary batch file content:

notepad.exe %*

Since the menu items are composed according the configuration folder file structure naming the files it is vital the proper naming convention is followed:

  • File name

    <two_digits_order_prefix>.<menu_item_name>[.c][.ms].<cmd|bat|ps1>
    
  • By default the batch file is executed with the console window hidden. If you prefer console being visible include .c suffix before the batch file extension.

  • .ms in the file name has special meaning. It indicates that the batch file supports multi-select scenario. Thus if multiple files are selected and executed against the shell extension menu item then every file will be executed in it's own process of the corresponding batch file. Otherwise, by default, all files are passed to a single batch file.

  • If you want the menu item to have the icon then place the icon file in the same folder where the corresponding batch file is and give it the same file name as the batch file but with the ".ico" extension:

    05.Shell-X configure.cmd
    05.Shell-X configure.ico
    

Note, you can use wild card expression as the folder name that encodes the pattern for the file name (of the file that is right clicked). However, since the wild card characters are prohibited by the file system you will need to use special characters that looke like the special wild card characters but are in fact special Unicode characters that are safe to use as folder names:

// The unicode characters that look like ? and * but still allowed in dir and file names
 string safeQuestionMark = ""; 
 string safeAsterisk = "";

Simply copy the characters from this description, compose the desired pattern in the text editor and then paste the pattern in the file explorer as a folder name.

Thus your desired pattern for files cmn.ar.00, cmn.ar.01,. . . will look like this: ⁎.ar.⁎.

Limitations

  • When user right-click a file and the plugin is loaded for the very first time there is a noticable delay (~3-5 seconds) before the menu pops up. This is a Windows Explorer one off limititation and any subsequent right-clicks bring context menu instantly.

shell-x's People

Contributors

jameswilliamknight avatar lbs-contributor avatar oleg-shilo avatar venipa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

shell-x's Issues

How to uninstall?

When installed manually, I can't delete the original shell-x.exe or SharpShell.dll. It is "in use".

There is no documentation on this, and this program is not visible in Windows "Apps and Features", startup, autoruns, or services.

How do I uninstall?

Removing icons is not possible because locking

Currently, removing icons is not possible because explorer.exe locks them.
There should be a way to remove the old added configuration without using LockHunter and restarting the computer.

PowerShell support

It would be nice to have PowerShell support for the openers. It is easier to write the openers using 00.something.ps1 rather CMD.

Crashes explorer window sometimes

It crashes the explorer window that I'm using the contextual menu on, closing the window and reopening it fixes the problem. The problem is random. Sometimes the shell-x menu dissapears. Sometimes the explorer window crashes and black or white rectangles start appearing on the window menues.

The most common is the contextual menu completely dissappearing and leaving a grey rectangle only:
2023-02-01 13-10-34

Env: Windows 10 x64 | 90+ custom menu entries each with icons

similar idea

Hello,

I just want to let you know that I believe your extension is similar to mine:

https://github.com/stax76/OpenWithPlusPlus

There is another one (unmaintained) called Open++ which is almost identical to mine but I had this idea independently.

Did you know either when you developed it? Both are over a decade old.

Shell extensions are best done in C++ (Raymond Chen).

My media player mpv.net uses your cs-script.

https://github.com/stax76/mpv.net

Greetings

Import current contexts from registry?

Would it be possible to pull in the existing context menu settings from the registry so changes can be made rather than having to recreate?

Maybe even including a batch file with the distro that can export the keys in question for parsing (so the program doesn't touch the registry directly)

Directory background support

Currently the [folder] target only works on right clicking folder icons. However it would be more useful if it also works on explorer's directory background. It would allow implementing menus similar to "Open in Windows Terminal" become possible.

Register for all the Users

Hi, I love what you did. It is really useful for me.

I wonder if it is possible to register the context menu so it appears on all the Users sessions ?

Incorrect context menu

Hello,
using [srt,mkv,mp4] folder to add context menu for srt, mkv and mp4 files.
But it is showing the context menu everywhere!
image

image

1.5.0.0 and spaces in filename

I'm mostly sure this worked in the last release. Now I can't seem to find any escape sequence that works at all. Currently I have just one shell-x entry: [any] 02.Edit in gVim.cmd gvim %*

Is there a way to properly escape this, or is this a regression?

Thanks

JSON configuration

It would be nice if we can configure the context menu using a JSON file. Something like this:

{
    "txt": {
        "Note editors": {
            "notepad": {
                "command": "notepad.exe %*",
                "image": "notepad.jpg"
            },
            "notepad++": {
                "command": "notepad++.exe %*",
                "image": "notepad++.jpg"
            }
        }
    }
}

[Request] Support for wildcard with file extensions

Some file formats might have a .00 appended to the actual file extension. This is the case with Sonic Unleashed/Generation's AR files.

2021-03-09_20-37-56_explorer

Because of this, shell-x won't accept anything under the ar folder, same with ar.00. The folder has to be 00 in order to work.

2021-03-09_20-39-56_explorer

2021-03-09_20-40-05_explorer

2021-03-09_20-40-18_explorer

Would it be possible to have shell-x have some sort of wildcard feature for cases like these, similar to ar.*?

Icon too big on nested context menu

When I put an icon for the nested context menu it appears to big.

The problem
immagine

The folder of the configuration:
immagine

I'm using the one it is included with the software, i've tried even with different icons from 32x32 and bigger, but the same happens.
I'm ond windows 10 and used chocolatey to install shell-x.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.