awtrobot

Headless environment error in java.awt.Robot class with MAC OS

余生颓废 提交于 2019-12-10 02:26:36
问题 I am trying to capture screen shots in my JavaFX application using Robot class, this is the code which I used in my application: Rectangle screenBounds = new Rectangle(Screen.getPrimary().getBounds().getWidth(), Screen.getPrimary().getBounds().getHeight()); Robot robot = new Robot(); BufferedImage img = robot.createScreenCapture(new java.awt.Rectangle( (int) screenBounds.getX(), (int) screenBounds.getY(), (int) screenBounds.getWidth(), (int) screenBounds.getHeight())); It is working perfectly

Get the location of a flash button

荒凉一梦 提交于 2019-12-08 06:40:06
问题 I have a flash button in my site, <object id="p17p316lo71o2j_flash" width="100%" height="100%" style="outline:0" type="application/x-shockwave-flash" data="http://testsite.com/includes/plupload/.../js/plupload.flash.swf"><param name="movie" value="http://testsite.com/includes/plupload/.../js/plupload.flash.swf"><param name="flashvars" value="id=p17p316lo71o2j"><param name="wmode" value="transparent"><param name="allowscriptaccess" value="always"></object>` is it possible to get the flash

awtrobot reads incorrect colors

萝らか妹 提交于 2019-12-07 16:10:16
问题 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 incorrect colors in OSX (other operating systems appear to get accurate colors) as noted in this question. I'm looking for either a workaround for this bug or any other library/language which will provide this functionality. Using the fairly simple code

Robot.delay(int) versus Thread.sleep(long)

僤鯓⒐⒋嵵緔 提交于 2019-12-07 11:36:30
问题 I have a program whose only purpose is to drive a java.awt.Robot in an infinite loop until an exit condition is met. The robot performs a number of actions in quick succession, which require a standard UI delay between them. For this, I use java.awt.Robot.setAutoDelay(int ms) , which appears to be designed for precisely this purpose. At other times, however, I need to insert arbitrarily long delays for operations to complete. I appear to have a choice between using java.awt.Robot.delay(int ms

How to match similar colours in Java using getRGB

对着背影说爱祢 提交于 2019-12-07 03:29:10
问题 I am taking screenshots of the screen using robot and then searching for smaller images within those screenshots. This works on Windows but not OS X because of gamma correction. The best solution I can come up with is to simply match similar colours instead of exact color matches. My fear is that matching similar colours will mean going beyond getRGB therefore will slow down my program (because it's taking multiple screenshots and comparing them to a smaller image to search for a match very

Does java.awt.Robot.waitForIdle() wait for events to be dispatched?

荒凉一梦 提交于 2019-12-06 21:13:12
问题 I'm using java.awt.Robot for integration tests of my Swing application, but I'm having trouble running my actions in the correct order. How can I tell the thread that calls robot.mousePressed(...) to block until Swing is finished dispatching that event? Apparently, robot.setAutoWaitForIdle(true) does no good. Here's my demo. I expect the "robot finished!" message to always come after "Action finished blocking.", but instead it often happens too soon instead. import java.awt.AWTException;

Testing keyboard input with java.awt.Robot

旧街凉风 提交于 2019-12-06 10:49:22
I have a test that exercises a custom Swing component using java.awt.Robot. I'd like to run the test in our build server, but the build servers run on locked windows machines, and Robot.keyPress(char) doesn't work with the screen locked. The keystrokes I'm sending are sometimes things like down arrow and backspace, so sending them directly to the document isn't helpful. Currently I'm just using junit's Assume to skip the tests if keyboard entry doesn't work on the first try, but I'd like to leave these test enabled. I would assume someone out there is running these kinds of tests against a

java.awt.Robot inside games?

柔情痞子 提交于 2019-12-06 09:03:39
问题 I'm trying to simulate a keystroke with the code below. When I open notepad it works fine but when I open the game in which I want to use it, it doesn't do anything. So keystrokes don’t seem to work. I tried to simulate mouse movement and clicks, those action do work. Does anyone know how to fix this problem? I found this question, How can I use java.awt.Robot inside games? but I can't add a comment or anything. package MyProject; import java.awt.AWTException; import java.awt.Robot; import

Java Robot mouse move: setting speed?

泄露秘密 提交于 2019-12-06 06:43:59
问题 The Java Robot class allows one to move the mouse as if the actual physical mouse was moved. However, how does one move the mouse from Point1 to Point2 in a humane (and thus not instant) manner? Aka, how does one set the speed of movement? If no such speed is possible with the Robot class, thus if the mouse can only be moved instantenously, what kind of "algorithm" should be used to mimic a human's mouse movement? Should it move the mouse pixel by pixel with a certain incrementing speed? 回答1:

awtrobot reads incorrect colors

亡梦爱人 提交于 2019-12-06 05:18:19
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 incorrect colors in OSX (other operating systems appear to get accurate colors) as noted in this question . I'm looking for either a workaround for this bug or any other library/language which will provide this functionality. Using the fairly simple code below can demonstrate the issue. public void printColorAtCoordinate(int x, int y) { Color color; color