Questions tagged [awtrobot]

The Robot class (java.awt.Robot) is used to programmatically trigger input events such as key press events and mouse actions & can also perform screenshot capture.

The Robot class (java.awt.Robot) is used to programmatically trigger input events, such as key press events and mouse actions & can also perform capture.

For Example:

Example of Java Robot Programming

662 questions
59
votes
6 answers

Programmatically clicking a GUI button in Java Swing

How would I programmatically click a Swing JButton in a way that would register all the relevant action/mouse events and be visible to the user (i.e. they'd see the button being pressed as if they actually clicked it)? The button is in the same…
Gigatron
  • 1,995
  • 6
  • 20
  • 27
54
votes
6 answers

How to simulate a real mouse click using java?

I'm attempting to perform a mouse click in Java, to click something in an external program. To do this, I'm using java.awt.robot, and the following code: Robot bot = new Robot(); int mask = InputEvent.MOUSE_BUTTON1_DOWN; bot.mouseMove(x, y); …
ali
  • 541
  • 1
  • 4
  • 5
48
votes
16 answers

Convert String to KeyEvents

I want to convert a String into KeyEvent to do something like this : writeKeyboard(myBot,"abcd"); public void writeKeyboard(Robot bot, String st){ char[] arr = arr.toCharArray(); int i = arr.length(); int j = 0; int keycode; …
Martin Trigaux
  • 5,311
  • 9
  • 45
  • 58
36
votes
7 answers

Type a String using java.awt.Robot

I already know how to use java.awt.Robot to type a single character using keyPress, as seen below. How can I simply enter a whole pre-defined String value at once into a textbox? …
user1196937
21
votes
3 answers

Java Robot Keypress Command Key

What is the VK_[key] code for the command key on a mac, if one exists? I am trying to get a Robot (java Robot) to press the command key. I am using the command keyPress(), and I need to know the integer keycode for the command key on a mac.
Abaab
  • 571
  • 1
  • 4
  • 15
17
votes
8 answers

File Upload using Selenium WebDriver and Java Robot Class

I am using Selenium WebDriver and Java and I need to automate the file upload feature. I tried a lot, but the moment the Browse button is clicked and a new window opens the script stops executing further and rather getting stuck. I tried in both…
Parikshit
  • 191
  • 1
  • 1
  • 5
14
votes
3 answers

Do Robot methods need to be run on the event queue?

Robot is part of the AWT library, but it seems quite different from most all the rest of the library. I am creating a Swing GUI that mixes Swing with Java Native Access (JNA) and Robot to allow Java to drive some MS Windows/Citrix work programs. My…
Hovercraft Full Of Eels
  • 283,665
  • 25
  • 256
  • 373
13
votes
1 answer

In continuous integration (headless env -> mac os X server), use a tool/lib which needs access to GUI, xvfb/display emulator/X11 forwarding

We have a Mac os x server (10.10.3) we use to run functional tests with Jenkins. We would like to use (in our tests) a tool/lib (sikulix for information) which uses under the hood java.awt.Robot class -java.awt.GraphicsEnvironment-. The problem is :…
Fanch
  • 3,274
  • 3
  • 20
  • 51
13
votes
1 answer

How can I programmatically generate keypress events?

What the java program should do is it should trigger keyboard press on some condition without a person pressing a keyboard key. So any program running in windows and in focus which requires keyboard input will get the input without a person actually…
Anubha
  • 1,345
  • 6
  • 23
  • 35
12
votes
4 answers

Is there a Python equivalent to Java's AWT Robot class?

Does anyone know of a Python class similar to Java Robot? Specifically I would like to perform a screen grab in Ubuntu, and eventually track mouse clicks and keyboard presses (although that's a slightly different question).
Stuart K
  • 3,212
  • 4
  • 22
  • 27
12
votes
3 answers

Robot.mouseMove does not work at all in Mac OS X

I created java file in IntelliJ IDE, with that code import java.awt.AWTException; import java.awt.MouseInfo; import java.awt.Robot; public class JavaRobotExample { public static void main(String[] args) { int x = 12, y =…
R.edd
  • 121
  • 1
  • 3
12
votes
2 answers

Increasing screen capture speed when using Java and awt.Robot

Edit: If anyone also has any other recommendations for increasing performance of screen capture please feel free to share as it might fully address my problem! Hello Fellow Developers, I'm working on some basic screen capture software for myself. As…
EthanLWillis
  • 930
  • 4
  • 14
  • 27
12
votes
8 answers

How can I control the keyboard and mouse with Python?

How can I control the mouse and keyboard in Python? The idea is to do the same as the Robot() class in Java. Be able to say: move the mouse from here to here, click there, write that whatever is on the screen. For Windows there is win32api but I'm…
Martin Trigaux
  • 5,311
  • 9
  • 45
  • 58
12
votes
3 answers

java print screen two monitors

I'm trying to use print screen image area to get 2 monitors, but only works for one monitor. Can you advise me how to get figure 2 monitors? Robot robot = new Robot(); Rectangle screenRect = new…
Faken143
  • 209
  • 1
  • 4
  • 10
12
votes
4 answers

Using Java to send key combinations

As per this previous link (How to send keyboard outputs) Java can simulate a key being pressed using the Robot class. However, how could a combination of key presses be simulated? If I wanted to send the combination "alt-123" would this be possible…
Muhammad Khan
  • 425
  • 1
  • 4
  • 14
1
2 3
44 45