JNA鼠标钩子的工作示例
谁能给我提供一个 JNA 鼠标钩子的工作示例,它能够在我的 Java Swing 应用程序之外跟踪鼠标移动/单击?
提前致谢
Can any one provide me with a working example of JNA mouse hook, which would be able to track mouse movements/click outside my Java Swing application ?
Thanks in Advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,这是代码...
这就是全部内容。干杯。
这基本上是抄袭 Sun 论坛中一个人的代码...但也经过我的测试,它的工作原理再次令人欢呼。
编辑:我编辑了代码,使其包含 LowLevelMouseProc,但您可以使用您可以在其他地方定义的 HOOK 扩展。没关系。请注意,由于某种原因,您必须将变量 mouseHook 设置为静态,否则钩子会在一段时间后取消钩子。
Yep, here is the code...
That's all about there is to it. Cheers.
It's a basically a ripoff of the code of a guy in Sun forums...but also tested by me, and it works so cheers again.
Edit: I edited the code so it includes the LowLevelMouseProc but you can use your extension of HOOK which you can define elsewhere. It doesn't matter that much. Be wary that for some reason you have TO have the variable mouseHook as static otherwise hook just unhooks after a while.
动作:
点击:
movements:
click: