• Stars
    star
    144
  • Rank 255,590 (Top 6 %)
  • Language
    C#
  • Created over 5 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Dynamic context menu manager for Windows.

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.

More Repositories

1

cs-script

C# scripting platform
C#
1,620
star
2

wixsharp

Framework for building a complete MSI or WiX source code by using script files written with C# syntax.
C#
1,110
star
3

cs-script.npp

CS-Script (C# Intellisense) plugin for Notepad++ (x86/x64)
C#
247
star
4

cs-script.core

.NET Core port of CS-Script
C#
100
star
5

codemap.vscode

Code map (syntax tree) of the active document
TypeScript
85
star
6

sublime-codemap

CodeMap - is a ST3 plugin for showing the code tree representing the code structure of the active view/document
Python
41
star
7

cs-script.vscode

VSCode extension for CS-Script
TypeScript
40
star
8

cs-script.net-framework

A mirror of the oleg-shilo/cs-script repository of CS-Script for .NET Framework. A copy of the repo before the product migration on .NET 5migrat
C#
30
star
9

Favorites.vscode

VSCode extension for managing Favorites
TypeScript
23
star
10

PyMap.VSIX

CodeMap extension for Visual Studio 2017-2022
C#
18
star
11

CodeMaidPlus

A simple extension that attempts to address some shortcomings of rather excellent CodeMaid.
C#
16
star
12

DocPreview.VSIX

C#
14
star
13

scripts.npp

C#
13
star
14

sublime-favorites

Favorites list for Sublime Text 3
Python
13
star
15

MoveTypeToFile.VSIX

"Move Type To File" Visual Studio 2017/2019 extension
HTML
10
star
16

multiclip

MultiClip
C#
10
star
17

Retired-VSIX

Repository of legacy Visual Studio extensions
10
star
18

cs-script-sublime

Sublime Text 3 plugin for CS-Script
Python
9
star
19

win-sudo

C#
8
star
20

GC-Menu

C#
7
star
21

LineMan.VSIX

Line manipulation extension for Visual Studio 2017
C#
6
star
22

CS-Script.VSIX

C#
5
star
23

StartApp

Instant launcher for heavy UI applications
C#
3
star
24

PropMan.VSIX

Property Manipulation Utilities for encapsulating fields, converting auto-properties to full properties and back.
C#
3
star
25

syntaxer.core

C#
3
star
26

mkshim

C#
3
star
27

syntaxer

C#
2
star
28

TailRecursion

C#
1
star
29

cs-script.sublime.dev

Python
1
star
30

CodeSnippets

C#
1
star
31

Stack-Analyser

A playground for dealing with call stack and assembly metadata
C#
1
star
32

ruta

C#
1
star
33

vscode-issue-reporting

TypeScript
1
star
34

CopyRefs.VSIX

C#
1
star
35

AsyncIt

C# code-generator analyzer for building Async/Sync API
C#
1
star