I controlled keyboard keys using java robot library, When i open microsoft word, i can see keys typing accurately.
But when i open a game, nothing happens.
Is game disabling IDE?
What should i do?
I controlled keyboard keys using java robot library, When i open microsoft word, i can see keys typing accurately.
But when i open a game, nothing happens.
Is game disabling IDE?
What should i do?
I could be wrong but I’m guessing you game hasn’t been clicked on and isn’t in focus. So your program is still simulating typing but it isn’t going to the right place. There’s this concept of focus within applications. Think of when you were writing this post, how did the computer know that you didn’t want to type in the search bar? This is because the text box was in focus and not the search bar. Normally programs represent focus with the cursor. The same applies for applications. Even if your game opens in full screen that doesn’t necessarily mean that the game is in focus. You could click on it manually but if you want it fully automated then you could just use the Robot class to click. If that’s what you want, try this when your game opens:
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
thanks, I’ll try it later, I have another thing to ask from you,
is there a default delay value for pressing a keyboard key ? … because some times my arduino board send serial data to processing IDE correctly, but processing doesn’t do his job well. when I send a single data ‘W’ form arduino to processing, processing type 2 or more results at a time.
explain me plz…
The Robot class has getAutoDelay()
and setAutoDelay()
methods. I’m not entirely sure how to use them but I think the delay is there because the computer needs some time to react to an event being triggered. You may have to play around with the auto delay if it’s causing problems. Sorry I can’t be more helpful I’ve never used those parts of the Robot class.