如何发送键和鼠标事件的Java小程序? [英] How to send key and mouse events to a Java applet?

查看:209
本文介绍了如何发送键和鼠标事件的Java小程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图控制从Firefox窗口一些Java游戏。我如何发送键和鼠标事件到Java小程序?

I'm trying to control some Java game from FireFox window. How can I send key and mouse events to that Java applet?

我使用Windows XP,如果是重要的。

I'm using Windows XP if that matters.

编辑:我并不想这样做与Java,即使我有标记在这里。一个C ++的解决方案是最优的。

I'm not trying to do this with Java even though i have the tag here. A c++ solution would be optimal.

推荐答案

您可以尝试使用的机器人,但是这可能不是工作在Firefox。您也可以使用像abstractbutton.doClick方法()

You might try using Robot, but this might not work in FireFox. You can also use methods like abstractbutton.doClick()

如果机器人不工作,你可以通过只在组件上设置文字综合,关键事件和鼠标事件,你可以使用doClick()和requestFocus()方法

If Robot doesn't work, key events you can synthesize by just setting text on a component, and mouse events you can use doClick() and requestFocus()

如果没有任何这样的作品,你也许能实现自己的目标使用JavaScript和HTML页面中工作。

If none of that works, you might be able to accomplish your goals working with javascript and an html page.

这篇关于如何发送键和鼠标事件的Java小程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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