如何在 Windows 上下文菜单中创建功能

发布于 2024-07-07 13:18:18 字数 565 浏览 5 评论 0原文

我使用 jsmin 来压缩我的 javascript 文件,然后再将其上传到生产环境。

由于我倾向于每页都有一个“代码隐藏”的 javascript 文件,因此我最终会经常这样做。

我安装了一个 Windows Powertoy,它在 Windows 资源管理器中添加了一个上下文菜单项,因此我可以“在此处打开命令窗口”。 当我单击该按钮时,命令提示符会在正确的目录中打开。 这可以节省一点打字时间。

但是,我仍然需要输入类似以下内容:

jsmin <script.js> script.min.js

才能使其正常工作。 这就麻烦了。

我想创建一个上下文菜单项,允许我右键单击 *.js 文件并选择“jsmin 压缩此文件”。 然后jsmin将被调用,原始文件将被压缩为“original_filename.min.js”

我该怎么做?

I use jsmin to compress my javascript files before uploading them to production.

Since I tend to have one "code-behind" javascript file per page, I wind up doing this a lot.

I installed a Windows Powertoy that adds a context menu item in Windows Explorer, so I can "Open Command Window Here". When I click that, the command prompt opens up in the right directory. That saves a little bit of typing.

However, I still have to type something like:

jsmin <script.js> script.min.js

To get it to work. This is a hassle.

I'd like to create a context menu item that will allow me to right-click on a *.js file and select "jsmin-compress this file." Then jsmin would be invoked, and the original file would be compressed into "original_filename.min.js"

How can I do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

浊酒尽余欢 2024-07-14 13:18:18

以下是如何向 .js 文件的上下文菜单添加条目:

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\JSFile\shell\JSMinify]
@="JSMinify" 

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\JSFile\shell\JSMinify\Command]
@="cmd.exe /c \"implement whatever cmd-friendly functions you want here (can use %1 and %%f) "

Here is how to add an entry to your context menu for .js files:

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\JSFile\shell\JSMinify]
@="JSMinify" 

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\JSFile\shell\JSMinify\Command]
@="cmd.exe /c \"implement whatever cmd-friendly functions you want here (can use %1 and %%f) "
奢华的一滴泪 2024-07-14 13:18:18

您可以将批处理脚本的链接放入用户 sendto 目录中。 类似的事情

jsmin %1 script.min.js

我通常会做

you could drop a link to a batch script into the user sendto directory. Something like

jsmin %1 script.min.js

which is what I usually do

你的他你的她 2024-07-14 13:18:18

您可以使用批处理文件并打开方式来完成此操作...

  Set jsminPath="C:\SomePath\jsmin.exe"
  %~d1 
  CD %~d1%~p1 
  %jsminPath% "%~n1.js" "%~n1.min.js" 

You could do it using a batch file and Open With...

  Set jsminPath="C:\SomePath\jsmin.exe"
  %~d1 
  CD %~d1%~p1 
  %jsminPath% "%~n1.js" "%~n1.min.js" 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文