0.4.2 • Published 5 years ago

win32shellmenu v0.4.2

Weekly downloads
5
License
MIT
Repository
github
Last release
5 years ago

win32shellmenu

This project is no longer maintained

Allows a node.js application to register a windows explorer context menu shell extension.

Intended to be used as part of the npm install / uninstall script.

Basic usage

var shellmenu = require( 'win32shellmenu' );

// An MSIL DLL is created as part of the registration process. The location to create this must be specified
// The same dll path will be required to unregister the shell extension
var dllname = 'mydll.dll';
var menu = [
	{
		// simple item with an icon image
		name: "Dynamic menu test - item 1",
		// "image" can specify a valid bmp / png to use as an icon image
		image: "icon.bmp"
	},
	{
		// specify an action to occur when clicked - will execute myjs.js with the argument arg1
		name: "Dynamic menu test - item 2",
		action: "myjs.js",
		args: [ "arg1" ],
		// can be "remain", "hidden" or "close" -> "remain" keeps the cmd window open after command has completed, "hidden" doesn't open a cmd window in the first place, and "close" closes the cmd window on completion
		style: "remain"
	},
	{
		name: "Dynamic menu test - item 3",
		// "children" property can mean to specify a submenu
		children: [
			{
				name: "Sub menu item 1",
				image: "icon.bmp"
			},
			{
				name: "Sub menu item 2"
			}
		]
	}
];

var options = {
	actionpath: __dirname, // Root folder which the script specified by "action" will be executed from - most applications will want this set to __dirname if they are being installed globally
	association: [ 'files', 'folders' ], // types of shell item to bind to - this can be either 'all', 'files', 'folders', 'imagefiles', 'videofiles', 'desktopbackground', 'drive' or 'printers'
	fileExtensionFilter: [ '.md' ] // filter by only these file extensions
};

shellmenu.register( dllname, menu, options, function( err ) {
	if ( err ) {
		console.error( err );
	}
});

Unregistering

var shellmenu = require( 'win32shellmenu' );
var dllname = 'mydll.dll';
// For "restartExplorer" to work correctly, process.exit() must be called, terminating the process.
// Set to false if you want to restart explorer yourself
// Callback will only be executed if restartExplorer is set to false
shellmenu.unregister( dllname, { restartExplorer: true }, function( err ) {} );
0.4.2

5 years ago

0.4.1

8 years ago

0.3.2

8 years ago

0.3.1

8 years ago

0.3.0

8 years ago

0.2.0

8 years ago

0.1.0

8 years ago