当某些软件正在运行时,Java Robot 关键活动似乎停止工作

发布于 2024-08-25 07:09:51 字数 716 浏览 5 评论 0原文

我正在编写一个 Java 应用程序,用于在一夜之间自动执行在线游戏中的角色动作(具体来说,它在《最终幻想 XI》中抓鱼)。该应用程序大量使用 java 的 Robot 类来模拟用户键盘输入和检测屏幕某些部分的颜色变化。它还使用多线程和 swing GUI。

当我在没有运行游戏的情况下测试该应用程序时,该应用程序似乎工作得很好,只需使用屏幕截图来触发应用程序对记事本的响应。但由于某种原因,当我真正启动 FFXI 并启动程序时,我所有的键盘和鼠标操作都完全停止工作。程序仍在运行,Robot 类仍然能够读取像素颜色。但是Robot.keyPress、Robot.keyRelease、Robot.mouseMove、Robot.mousePress 和Robot.mouseRelease 都不执行任何操作。这是最奇怪的事情 - 为了测试它,我编写了一个简单的循环,它只是不断输入字母,并聚焦记事本。然后我开始游戏,重新聚焦记事本,但它什么也没做。然后我退出游戏,它会立即重新开始工作。

有没有其他人遇到过这样的事情,特定的软件会阻止java的某些功能工作?

另外,为了让这更有趣——去年我编写了一个非常相似的程序,使用相同的类和编程技术来自动治疗游戏中战斗的一方。去年,这个计划运行得非常完美。遇到这些问题后,我挖出了那个旧程序,在不做任何更改的情况下运行它,发现它也有同样的问题。现在和工作时的唯一区别是:我运行的是 Windows Vista,现在运行的是 Windows 7,并且已经发布了几个新的 Java 版本以及 FFXI 版本。

到底是怎么回事?

I'm writing a Java application to automate character actions in an online game overnight (specifically, it catches fish in Final Fantasy XI). The app makes heavy use of java's Robot class both for emulating user keyboard input and for detecting color changes on certain parts of the screen. It also uses multithreading and a swing GUI.

The application seems to work perfectly when I test it without the game running, just using screenshots to trigger the apps responses into notepad. But for some reason, when I actually launch FFXI and start the program, all of my keyboard and mouse manipulations just stop working altogether. The program is still running, and the Robot class is still able to read pixel colors. But Robot.keyPress, Robot.keyRelease, Robot.mouseMove, Robot.mousePress and Robot.mouseRelease all do nothing. It's the strangest thing-- to test it, I wrote a simple loop that just keeps typing letters, and focused notepad. I'd then start the game, refocus notepad, and it would do nothing. Then I'd exit the game, and it'd start working again immediately.

Has anyone else come across something like this, where specific software will stop certain functions of java from working?

Also, to make this more interesting-- Last year I wrote a very similar program using the same classes and programming techniques to automate healing a party in the game as they fight. Last year, this program worked perfectly. After running into these problems I dug up that old program, ran it without making any changes, and found that it too was having the same problems. The only differences between now and when it was working: I was running Windows Vista and now I'm running Windows 7, and several new Java versions as well as FFXI versions have been released.

What is going on?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

倾城花音 2024-09-01 07:09:51

FFXI 有防止作弊的代码。看起来相当有效。

FFXI has code to prevent cheating. Quite effectively, it would seem.

年华零落成诗 2024-09-01 07:09:51

如果可能,在 WinXP 中尝试。我自己也为在线游戏编写了一个机器人,它使用了许多相同的概念(即使用 Java Robot 读取像素颜色并模拟按键和鼠标点击)。

在WinXP下:
机器人在所有情况下都按预期工作。

Win7下:
在游戏之外,机器人按预期工作。在游戏中,模拟输入失败(我认为像素读取还可以)。

If possible, try it in WinXP. I myself have also written a bot for an online game that uses much of the same concepts (i.e. using Java Robot to read pixel colors and simulate key-presses and mouse-clicks).

Under WinXP:
Bot works as intended in all cases.

Under Win7:
Outside of the game, bot works as intended. Ingame, simulated input failed (pixel reads were okay, I think).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文