Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Integrate an option to explorer context menu with Electron

I'm building an app which should be integrated through an option in the context menu of Windows explorer and Mac finder. I couldn't find a relevant option in Electron's documentation.

For example, when I right-click a file in Windows explorer / Mac finder, I want this option from my Electron app to appear in that menu. Is it possible?

like image 644
Mouli Avatar asked Oct 14 '15 06:10

Mouli


People also ask

How do I add to Explorer context menu?

Right-click (or select and hold) on a file or folder to open the context menu. Select Show more options.

How do you change the electron menu?

const electron = require('electron'); const { app, BrowserWindow, Menu } = electron; let mainWindow; app. on('ready', () => { mainWindow = new BrowserWindow({}); mainWindow. loadURL(`file://${__dirname}/main.html`); const mainMenu = Menu. buildFromTemplate(menuTemplate); Menu.

How do I hide menu in electron app?

The only workaround is to use Menu. setApplicationMenu(null) , however, this will disable all the menu shortcuts like F11 for toggling fullscreen etc. In new versions of Electron, you can set autoHideMenuBar: true while creating browserWindow, pressing Alt will show the menu bar again.


1 Answers

This question is not actually related to Electron. It can be divided into two parts:

  1. Creating custom dynamic context menu entries during installation passing the respective selected file as command line argument to its target
  2. Node.js command line argument parsing

Creating custom dynamic context menu entries during installation

Windows:

  • Adding context menu entries during installation using WiX
  • Since it boils down to adding registry keys, this more general SO post about adding context menu entries for specific file types may also interest you.

OSX:

  • I really can't tell.

Node.js command line argument parsing

Multiple options exist for command line argument parsing in Node.js, here is just a handful I've been using in the past:

  • Minimist
  • command-line-args
  • and my current favourite, Yargs
like image 79
Jens Habegger Avatar answered Oct 20 '22 21:10

Jens Habegger