Windows上下文菜单 - 项目的可见性(如果剪贴板包含文本) [英] Windows context menu - visibility of the item (if clipboard contains text)

查看:97
本文介绍了Windows上下文菜单 - 项目的可见性(如果剪贴板包含文本)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

屏幕

我在app上处理复制和粘贴文件名。我已经有一个带有小子应用程序的工作上下文菜单(用c#编写),但我想只有当剪贴板包含一些文本时才会看到粘贴选项。怎么做?可以通过向注册表添加内容吗?



我尝试过:



我不知道。下面的Windows注册表中的键。

注册表项上下文菜单:

 [HKEY_CLASSES_ROOT \ * \ shell * \\ CopyPasteFileName] 
SubCommands=cfn; cfp; pfn; pfnne
icon=C:\\Users\\KN \\Desktop \\files \\\\icon .ico
位置=底部



粘贴文件名密钥:

 [ HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows \ CurrentVersion\Explorer \ CommandStore \shell \ pfn] 
@ =粘贴文件名
[HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion\Explorer \CommandStore \shell\pfn\command]
@ =C:\\Program Files \\CopyPasteFileName \\ pfn.exe \ %1 \



其他菜单项有类似的键

解决方案

没有什么可以放入注册表将完成如果有的话剪贴板上的东西东西。您将不得不为此提供实际代码并即时修改上下文菜单。



唯一的方法是编写一个shell延期。这是来自一小段代码的FAR。值得庆幸的是,这里有一些关于CP的系列文章,包括 .NET Shell扩展 - Shell上下文菜单 [ ^ ]和 .NET中的Explorer Shell扩展(已修订) [ ^ ]。


请参见此处: Clipboard.ContainsText Method(System.Windows.Forms) [ ^ ]

Screen
I work on app to copy and paste filenames. I already have a working context menu with little subapps (written in c#), but I would like to that paste options will be visible only if clipboard contains some text. How to do it? Is it possible by add something to registry?

What I have tried:

I have no idea. Keys in Windows registry below.
Registry key context menu:

[HKEY_CLASSES_ROOT\*\shell\CopyPasteFileName]
"SubCommands"="cfn;cfp;pfn;pfnne"
"icon"="C:\\Users\\KN\\Desktop\\files\\icon.ico"
"Position"="Bottom"


Paste filename keys:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\pfn]
@="Paste Filename"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\pfn\command]
@="C:\\Program Files\\CopyPasteFileName\\pfn.exe \"%1\""


Other menu items have similar keys

解决方案

There's nothing you can put into the registry that's going to do the whole "If there's something on the clipboard" thing. You're going to have to provide actual code for that and modify the context menu on-the-fly.

The only way to do that is to write a shell extension. This is FAR from a trivial piece of code to write. Thankfully, there's a couple series of articles here on CP that covers this, like .NET Shell Extensions - Shell Context Menus[^] and Explorer Shell Extensions in .NET (Revised)[^].


See here: Clipboard.ContainsText Method (System.Windows.Forms)[^]


这篇关于Windows上下文菜单 - 项目的可见性(如果剪贴板包含文本)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆