VB.NET剪贴板管理器 [英] VB.NET Clipboard Manager
问题描述
我知道这个主题已经有很多资源了但是我还有其他一些相关的问题。
好的,所以我的第一个问题是关于系统范围的热键这是如何实现的,因为我还没有找到一个有效的解决方案。我需要能够按[Ctrl + Alt + V]来显示上下文菜单。
我的第二个问题是它的上下文菜单自我和剪贴板,我希望用户能够单击上下文菜单中的项目并将其粘贴到活动的应用程序中;有没有办法做到这一点,因为我还没有看到一个?
感谢您的帮助
I know there are already many resources on this topic however I have some other questions that are related.
Okay so my first question is about system wide hot keys, how is this achieved exactly because I haven''t been able to find a working solution. I need to be able to press [Ctrl + Alt + V] for example to show a context menu.
My second question is about the context menu it''s self and the clipboard, I want the user to be able to click an item in the context menu and it be pasted into the active application; is there a way to do this as I haven''t yet seen one?
Thanks for any help
推荐答案
首先,您可以添加自定义键盘查看器和键盘格式侦听器。
http://msdn.microsoft.com/en-us/library/windows/desktop/ms649052%28v=vs .85%29.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/windows/desktop/ms649033%28v=vs.85%29.aspx [< a href =http://msdn.microsoft.com/en-us/library/windows/desktop/ms649033%28v=vs.85%29.aspxtarget =_ blanktitle =New Window> ^ ]。
您可以通过P / Invoke使用此方法。这已经为您完成了:
http://www.pinvoke.net/default .aspx / user32.setclipboardviewer [ ^ ],
http://www.pinvoke.net /default.aspx/user32/AddClipboardFormatListener.html?diff=y [ ^ ]。
请参阅其他剪贴板Windows API(左上角的前两个链接)。 />
如果您还需要其他东西,还可以添加全局钩子和捕获键盘输入。我认为你不需要它,但我完全不知道你的目标。 (最好从解释你的最终目标开始你的问题。)
-SA
To start with, you can add your custom keyboard viewer and a keyboard format listener.
http://msdn.microsoft.com/en-us/library/windows/desktop/ms649052%28v=vs.85%29.aspx[^],
http://msdn.microsoft.com/en-us/library/windows/desktop/ms649033%28v=vs.85%29.aspx[^].
You can use this method via P/Invoke. This is already done for you:
http://www.pinvoke.net/default.aspx/user32.setclipboardviewer[^],
http://www.pinvoke.net/default.aspx/user32/AddClipboardFormatListener.html?diff=y[^].
See other clipboard Windows API (first two link, on the left).
If you need something else, you can also add a global hook and capture keyboard input. I don''t think you would need it, but I don''t know your goals exactly. (It''s the best to start your questions from explaining your ultimate goals.)
—SA
>
我认为你正在寻找的是Keypress活动。
在这里看看这个词。
或者这个。
http://vb.net-informations.com/gui/key-press-vb.htm [ ^ ]
或者这里
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.keypress( v = vs.90).aspx [ ^ ]
除非您必须使用这些键,否则为什么不使用工具箱中的上下文菜单条。
或者只需编写代码。
http://msdn.microsoft.com/en-us/library/system.windows.forms.contextmenustrip(v = VS.90)的.aspx 一> [ ^ ]
然后是使用剪贴板的问题。 My.Computer.Clipboard。
http ://msdn.microsoft.com/en-us/library/a2kwzzs8(v = vs.90).aspx [ ^ ]
What I think you are looking for is the Keypress event.
Look that word up here.
Or this one.
http://vb.net-informations.com/gui/key-press-vb.htm[^]
or here
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.keypress(v=vs.90).aspx[^]
Unless you Just had to use those keys,why not use a context Menu Strip from the tool box.
Or just write the code.
http://msdn.microsoft.com/en-us/library/system.windows.forms.contextmenustrip(v=vs.90).aspx[^]
Then it is a matter of using the clipboard. "My.Computer.Clipboard."
http://msdn.microsoft.com/en-us/library/a2kwzzs8(v=vs.90).aspx[^]
在钩子回调中你可以调用 GetKeyState [ ^ ]获取状态修改键。
其余的是一些聪明的编码。
Inside the hook callback you can call GetKeyState[^] to get the status of the modifer keys.
The rest is some clever coding.
这篇关于VB.NET剪贴板管理器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!