简体   繁体   English

电子内部或外部方法来创建自己的右键单击上下文菜单-Windows

[英]Electron internal or external method to create own right click context menu - Windows

Hello Stack Community :) I have an Electron project and was wondering if it is possible to add an own row to the windows right click context menu. 你好,堆栈社区:)我有一个Electron项目,想知道是否可以在Windows右键单击上下文菜单中添加自己的行。 As example here cmder does the same. 作为示例,cmder的操作相同。

right click context menu 右键单击上下文菜单

Edit:From the comment below it worked with registry editor to create an own row. 编辑:从下面的注释中,它与注册表编辑器一起创建了自己的行。 But it will only open when you make right click into an empty area of the folder window. 但是,只有在右键单击文件夹窗口的空白区域时,它才会打开。 But for my Electron project I need to make right click on a folder/file as example and then I need the path structure of the file/folder sended to the terminal and executed as echo example that I can match the path via stdout in node.js. 但是对于我的Electron项目,我需要右键单击一个文件夹/文件作为示例,然后需要发送到终端并作为回显示例执行的文件/文件夹的路径结构,以便可以通过node中的stdout匹配该路径。 js。 Also an alternative way would be if the path structure gets saved in an external file .txt as example. 另外一种替代方法是,例如,将路径结构保存在外部文件.txt中。 Any ideas for this without c++, c#, .net experience? 没有c ++,c#、. net经验的任何想法? I´am only familiar with web languages. 我只熟悉网络语言。 Thank you for any help! 感谢您的任何帮助!

Hey there you could use atoms implementation of this. 嘿,你可以使用原子实现。

Basicaly you use the package winreg to register/unregister the information. 基本上,您使用软件包winreg来注册/注销信息。

The registry entries and how Atom does this can be found in atoms win-shell.js file at https://github.com/atom/atom/blob/master/src/main-process/win-shell.js 注册表条目以及Atom如何做到这一点可以在https://github.com/atom/atom/blob/master/src/main-process/win-shell.js的 atom win-shell.js文件中找到

  • exports.fileHandler is the open with ... one (option 1) exports.fileHandler是打开的...(选项1)
  • exports.fileContextMenu is option 2 for all files on your system exports.fileContextMenu是系统上所有文件的选项2
  • exports.folderContextMenu is option 2 for all folders on your system exports.folderContextMenu是系统上所有文件夹的选项2
  • exports.folderBackgroundContextMenu is option 2 when you right-click inside a folder not on any specific file. 当您右键单击文件夹中的文件夹而不是任何特定文件时,exports.folderBackgroundContextMenu是选项2。

Depending on the context you then need to parse the arguments etc. normally this would be the filepath(s). 然后,根据上下文,您需要解析参数等。通常,这将是文件路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM