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
4
votes
2 answers

Screen Capture in Java not capturing whole screen

I have a small piece of code that I use to keep track of time - very simply it takes a picture of my desktop every four minutes so that later I can go back over what I've been up to during the day - It works great, except when I connect to an…
Joe
  • 4,367
  • 7
  • 33
  • 52
3
votes
1 answer

Accent with robot keypress

I've been trying to use Robot from awt, to input some text on a app. The problem it's that i can't make it type any letters like ê, à or á. I have tried doing this such printing ^e for example but even that works, it just dosen't print anything for…
Ismael Abreu
  • 16,443
  • 6
  • 61
  • 75
3
votes
1 answer

Java's createScreenCapture not working on OS X, produces completely wrong colours

If I run this code: BufferedImage image = new Robot().createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize())); ImageIO.write(image, "png", new File("takenwithrobot.png")); It yields the following PNG:…
David Zorychta
  • 13,039
  • 6
  • 45
  • 81
3
votes
2 answers

Making mouse movements humanlike (using an arc rather than a straight line to the destination)

I am making and auto clicker using java.awt.Robot. One of the concerns i have however is the movements aren't very humanlike. Can anyone suggest some changes to my code to make it more human like? Right now it just moves in a straight line. /** * …
Michael Rentmeister
  • 167
  • 1
  • 6
  • 24
3
votes
0 answers

awtrobot reads incorrect colors

I'm looking for a platform-independent way to read colors from the screen and simulate user input through mouse and keyboard actions. I have previously been using java.awt.robot, however some time in the past 2 years it has started reporting…
Eldrad
  • 31
  • 1
3
votes
5 answers

Is there an equivalent to Java's Robot class (java.awt.Robot) for Perl?

Is there an equivalent to Java's Robot class (java.awt.Robot) for Perl?
whitney
  • 356
  • 4
  • 5
3
votes
2 answers

Listeners in conjunction with Robot class

I've been playing with the Robot class recently and I have it doing what I want, but I haven't figured out how to interrupt/stop its actions via user input. For example: I want it to click the desktop a hundred times but I decide forty clicks in…
Rhyono
  • 2,420
  • 1
  • 25
  • 41
3
votes
1 answer

How does Robot's getPixelColor(int x, int y) method work?

How exactly does the method getPixelColor(int x,int y) from the Robot class work? I tried this code fragment: try { Robot robos = new Robot(); } catch (AWTException e) { } for (int i = 0; i < 100; i++) robos.getPixelColor(0,…
blenddd
  • 345
  • 1
  • 6
  • 15
3
votes
3 answers

Java Full Screenshot

I wanted to display on the JFrame on the program the full screenshot of my screen. So far using the code below, I was able only to display part of the screen. The code below is the content of the paint(Graphics g). How can I make it full screen? //…
Cyril Horad
  • 1,555
  • 3
  • 23
  • 35
3
votes
1 answer

Java - screenshot window while in runnable jar file not working

I'm trying to take a screenshot of my window with the following command. BufferedImage screenCapture = new Robot().createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize())); ImageIO.write(screenCapture, "jpg",…
Abdul
  • 73
  • 6
3
votes
1 answer

javafx.scene.robot.Robot vs java.awt.Robot

I just read that JavaFX has its own javafx.scene.robot.Robot class. How does it differ from java.awt.Robot? I also don't really understand why Robot class was packed in java.awt package instead of e.g. java.util as it doesn't seem to be related to…
J. Doe
  • 79
  • 1
  • 1
  • 5
3
votes
3 answers

How can I simulate a mousePressed event without using java.awt.robot?

I want to simulate a mousePressed event in Java, I found out that I can use the Robot class for this, and it works, but only in Windows and not in Mac OS X. Does anyone know of an alternative way to simulate a mousePressed event? This is the code I…
Jesse
  • 1,332
  • 2
  • 14
  • 25
3
votes
1 answer

java.awt.Robot works strangely under macOS Mojave

After macOS was upgraded to Mojave, java application that is using Java Robot and works absolutely fine under High Sierra, stars to work incorrectly. Symptoms are: robot.keyPress(VK_N); causes the about 7 the same errors and did not type…
3
votes
1 answer

Selenium WebDriver get element SCREEN Coordinates

I want to get the on screen coordinates of a WebElement and use the robot class to click on it. SeleniumMethods sl= new SeleniumMethods(); WebDriver driver = new FirefoxDriver(); public void example () throws Exception{ …
Hills
  • 33
  • 2
  • 5
3
votes
2 answers

Why do we need Robot class when we have Actions class in selenium

I was going through the selenium learning and when I was exploring interaction with keyboard and mouse topic, I found this code. With the help of Robot class,perform Enter : Robot r=new Robot(); r.keyPress(KeyEvent.VK_ENTER); With the help of…
Rupali
  • 109
  • 1
  • 2
  • 8