Kon*_*ter 2 python windows shell cascade
我正在尝试添加*.zip文件的上下文菜单.用nessesary参数启动我的python脚本.
我已添加注册以下键:
[HKEY_CLASSES_ROOT\WinZip\shell\SSSeracher] "MUIVerb"="SSSearcher Script" "SubCommands"="SSSearcher.Rule1;SSSearcher.Rule2;SSSearcher.Rule3;SSSearcher.Custom;SSSearcher.Config"
[HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\SSSearcher.Rule1] @="Rule #1"
[HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\SSSearcher.Rule1\command] @="C:\\APPS\\python\\Scripts\\sssearcher.py \"%1\" \"1\""
[HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\SSSearcher.Rule2] @="Rule #2"
[HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\SSSearcher.Rule2\command] @="C:\\APPS\\python\\Scripts\\sssearcher.py \"%1\" \"2\""
[HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\SSSearcher.Rule3] @="Rule #3"
[HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\SSSearcher.Rule3\command] @="C:\\APPS\\python\\Scripts\\sssearcher.py \"%1\" \"3\""
[HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\SSSearcher.Custom] @="Custom rule"
[HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\SSSearcher.Custom\command] @="C:\\APPS\\python\\Scripts\\sssearcher.py \"%1\" \"4\""
[HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\SSSearcher.Custom] @="Custom rule"
[HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\SSSearcher.Custom\command] @="C:\\APPS\\python\\Scripts\\sssearcher.py \"%1\" \"4\""
[HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\SSSearcher.Config] @="Config File"
[HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\SSSearcher.Config\command] @="vim C:\\APPS\\python\\Scripts\\sssearcher.pyc"
Run Code Online (Sandbox Code Playgroud)
当菜单显示点击那些绝对没有.
我一直在关注这个教程:http: //msdn.microsoft.com/en-us/library/windows/desktop/hh127467%28v=vs.85%29.aspx
我遗漏了一些东西,但不幸的是我找不到答案.你能帮帮我吗?
我刚刚按照这些步骤进行操作:
1)首先找到.zip钥匙HKEY_CLASSES_ROOT.
2)选择它并查看其默认值.在我的情况下,默认值是CompressedFolder:

3)现在导航到CompressedFolder\shell(或者你的默认为.zip的东西),它也包含在HKEY_CLASSES_ROOT:

4)右键单击shell并添加一个新密钥,在我的情况下,我添加了一个名为的密钥MyCommand.在此密钥中添加一个名为的子项command.MyCommand将是上下文菜单中显示的命令的名称.

5)接下来编辑子项的(Deafult)条目值,添加您想要执行的操作.在我的情况下,我想打开一个python文件,告诉我有关该文件的详细信息:commandmycommand
这是python脚本:
import os
import sys
def main():
st = os.stat(sys.argv[1])
print st
raw_input()
if __name__ == '__main__':
main()
Run Code Online (Sandbox Code Playgroud)
它位于C:\ info.py
这是我添加到默认值的条目:
python C:\\info.py %1

这就是它的全部内容,现在如果您右键单击一个zip文件,您应该会看到您添加的命令:

点击时给出:

希望这就是你所追求的.如果您想添加更多命令,那么只需在键下添加更多子shell键,就像我们一样MyCommand.
更新 - 级联菜单
a)为了添加级联菜单,导航到上面在步骤3中说明的键.在我的情况下,CompressedFolder\shell这是在HKEY_CLASSES_ROOT下.在这里添加一个带有您选择名称的密钥,在我使用的情况下CascadeMenu.在此密钥中添加2个条目:
MUIVerb - 这是为级联菜单显示的名称.就我而言,我已经习惯了MyCascadeMenuSubCommands - 这是一个以分号分隔的命令列表.根据我使用的情况命名命令,无论你喜欢什么python.info.使用'|' 例如,如果你想要一个分隔符,请在命令之间command1;|;command2
b)接下来我们需要告诉windows这个命令实际上做了什么.导航:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\Shell
在这里添加一个带有命令名称的密钥.在我的情况下,密钥被调用python.info.将键的默认值设置为要在上下文菜单中显示的名称.就我而言,我已经习惯了"File Info"

c)现在为命令添加一个子键,称为command.将此命令的默认条目更改为您要执行的命令.在我的情况下,我把它设置为python C:\\info.py %1

d)我们现在完成了,右键单击.zip文件以查看新创建的上下文菜单:

| 归档时间: |
|
| 查看次数: |
1415 次 |
| 最近记录: |