# Java robot library doesn't work with fullscreen games

**URL:** <https://discourse.processing.org/t/java-robot-library-doesnt-work-with-fullscreen-games/6835>\
**Category:** Electronics (Arduino, etc.)\
**Created:** [December 23, 2018, 5:44am UTC](https://discourse.processing.org/t/java-robot-library-doesnt-work-with-fullscreen-games/6835 "2018-12-23T05:44:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kavindaveerakoon](https://avatars.discourse-cdn.com/v4/letter/k/bbce88/32.png) [@kavindaveerakoon](https://discourse.processing.org/u/kavindaveerakoon)\
**Post date:** [December 23, 2018, 5:44am UTC](https://discourse.processing.org/t/java-robot-library-doesnt-work-with-fullscreen-games/6835/1 "2018-12-23T05:44:05Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![figraham](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/figraham/32/4161_2.png) [@figraham](https://discourse.processing.org/u/figraham)\
**Post date:** [December 23, 2018, 6:15am UTC](https://discourse.processing.org/t/java-robot-library-doesnt-work-with-fullscreen-games/6835/2 "2018-12-23T06:15:02Z")

</div>

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:

```auto
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);

```

---

<div class="post-metadata">

**Author:** ![kavindaveerakoon](https://avatars.discourse-cdn.com/v4/letter/k/bbce88/32.png) [@kavindaveerakoon](https://discourse.processing.org/u/kavindaveerakoon)\
**Post date:** [December 23, 2018, 7:21am UTC](https://discourse.processing.org/t/java-robot-library-doesnt-work-with-fullscreen-games/6835/3 "2018-12-23T07:21:50Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![figraham](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/figraham/32/4161_2.png) [@figraham](https://discourse.processing.org/u/figraham)\
**Post date:** [December 23, 2018, 7:52am UTC](https://discourse.processing.org/t/java-robot-library-doesnt-work-with-fullscreen-games/6835/4 "2018-12-23T07:52:23Z")

</div>

The Robot class has [`getAutoDelay()` and `setAutoDelay()` methods](https://docs.oracle.com/javase/8/docs/api/java/awt/Robot.html#getAutoDelay--). 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.
