如何使用java.awt.Robot中里面的游戏吗? [英] How can I use java.awt.Robot inside games?

查看:417
本文介绍了如何使用java.awt.Robot中里面的游戏吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发,控制PC键盘和鼠标的Andr​​oid应用程序。我想添加一个新功能(使用手机作为游戏控制器)。我使用 java.awt.Robot中的
它工作在控制键盘和鼠标的罚款。但是,当我与游戏中使用它, java.awt.Robot中的没有preSS按钮。当我去游戏外,它工作再次罚款。

I am developing an Android application that controls the PC keyboard and mouse. I wanted to add a new feature (using your mobile as a game controller). I am using java.awt.Robot. It works fine in controlling the keyboard and mouse. But when I used it with games, java.awt.Robot doesn't press buttons. When I go outside the game, it works fine again.

例如:

if (senderPropertyOne.equalsIgnoreCase("l")) {
    robot.keyPress(KeyEvent.VK_LEFT);
    robot.keyRelease(KeyEvent.VK_LEFT);
} else if (senderPropertyOne.equalsIgnoreCase("r")) {
    robot.keyPress(KeyEvent.VK_RIGHT);
    robot.keyRelease(KeyEvent.VK_RIGHT);
} else if (senderPropertyOne.equalsIgnoreCase("u")) {
    robot.keyPress(KeyEvent.VK_UP));        
    robot.keyRelease(KeyEvent.VK_UP);
} else if (senderPropertyOne.equalsIgnoreCase("d")) {
   robot.keyPress(KeyEvent.VK_DOWN);
   robot.keyRelease(KeyEvent.VK_DOWN);

这工作正常Flash游戏在互联网上,但是当我启动我的电脑上一场正常的比赛(如实况足球),这是行不通的。

This works fine in Flash games on the internet, but when I launch a normal game on my PC (like pro evolution soccer), it doesn't work.

推荐答案

感谢大家没有协助我。我设法解决这个问题,公布的Andr​​oid应用程序与下载100000:)

Thank you all for not assisting me. I managed to fix the issue, published Android app with 100000 downloads :)

我是开发Android应用程序,让Android手机控制电脑并使用Android手机作为游戏控制器PC。我用的是TCP和面临那我无法控制比赛​​thae问题。

I was developing an android app that let Android phone control PC and use Android phone as a game controller for PC. I was using TCP and faced thae issue that I cant control games.

当我用UDP代替,这个问题解决。我不知道TCP是根本原因或没有,但现在我的问题,固定和我的应用程序的Andr​​oid市场:)

When I used UDP instead, the issue fixed. I dont know TCP was the root cause or not but my issue fixed now and my app published on Android market :)

这篇关于如何使用java.awt.Robot中里面的游戏吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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