拦截并修改发送给第三方应用程序的鼠标事件?
如何在鼠标事件(x/y 坐标、加速度等)到达第三方应用程序之前通过 Java 拦截和修改它们?
该应用程序是预先已知的(因此,如果有帮助的话,类似“java myApp 3rdPartyApp”的内容是可能的)。请注意,第三方应用程序可能非常占用资源。
我想我要问的是如何制作一个Java应用程序作为真实鼠标事件和第三方应用程序之间的一层,以便第三方应用程序接收修改后的事件而不是由鼠标发送的原始事件操作系统?这对于 Java 来说是可能的吗?
How can I intercept and modify mouse events (x/y coordinates, acceleration, etc.) via Java, before they reach a third party application?
The application is known beforehand (so something like "java myApp 3rdPartyApp" is possible, if it helps). Do note that the third-party application may be very resource-intensive.
I guess what I'm asking is how can I make a Java app that serves as a layer between the real mouse events and the third-party application so that the third-party app receives the modified events but not the original ones sent by the OS? Is this even possible with Java?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你有2个纯java解决方案。
首先,您可以连接到 AWT 事件队列并获取所有 UI 事件:
Toolkit.getDefaultToolkit().getSystemEventQueue()
不幸的是,我不确定您可以修改这些事件,但您可以阅读它们并且可以模拟事件。
其次,您可以在第三方应用程序上创建透明窗口,您可以在其中捕获所有 UI 事件,然后使用 java.awt.Robot 模拟它们。
请参阅此处如何创建透明窗口。我尝试了这个方法,发现效果很好。
You have 2 pure java solutions.
First, you can connect to the AWT event queue and get all UI events:
Toolkit.getDefaultToolkit().getSystemEventQueue()
Unfortunately I am not sure you can modify these events but you can read them and you can simulate events.
Second you can create transparent window over your third party application where you can catch all UI events and then simulate them using
java.awt.Robot
.Please see here how to create transparent window. I tried this method and see that it works well.