简体   繁体   English

我如何收听未针对我的应用程序的剪贴板粘贴?

[英]How can I listen for clipboard pastes not targeted at my application?

I'm developing an application which calculates and displays information which then needs to be copy and pasted into a proprietary program. 我正在开发一个计算和显示信息的应用程序,然后需要将其复制并粘贴到专有程序中。 To make this easier for the user, I'd like to enable them to ctl + v , move cursor, ctl + v , etc., and have my program pick up on the pastes and update the Clipboard automatically after every paste. 为了使用户更容易使用,我想让他们使用ctl + v ,移动光标, ctl + v等,并使我的程序在粘贴中拾取并在每次粘贴后自动更新剪贴板

Is there any straightforward way of doing this? 有没有简单的方法可以做到这一点? The only things I've found involve accessing DLLs and the like, and this isn't a project I can spend too much time on at the moment. 我发现的唯一内容涉及访问DLL之类的东西,这不是我目前可以花费太多时间的项目。

It's possible, check this project out: https://code.google.com/p/jnativehook/ 有可能,请检查此项目: https : //code.google.com/p/jnativehook/

That will allow you to listen to key events even when your app doesn't have focus. 即使您的应用没有重点关注,它也可以让您聆听关键事件。 It won't work if they don't paste with a keyboard shortcut, though. 但是,如果他们不粘贴键盘快捷键,它将无法正常工作。

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

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