awtrobot

Alt+Tab using Java Robot

余生颓废 提交于 2019-12-05 23:41:08
问题 I am trying to bring up the alt + tab menu with a Java Robot. When I call the alt_tab() method, I want to bring up the alt + tab menu and keep the menu up. I know this can be achieved using alt + ctrl + tab . So far I have tried the code below, and also just alt + tab without the control key. I am not sure why it's not bringing up the menu. All it does is emulate pressing the alt key. public void alt_tab() { Robot robot = new Robot(); robot.keyPress(KeyEvent.VK_ALT); robot.keyPress(KeyEvent

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

六眼飞鱼酱① 提交于 2019-12-05 11:51:41
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) or java.lang.Thread.sleep(long ms) , and am curious what the differences between them are, and which

How to match similar colours in Java using getRGB

三世轮回 提交于 2019-12-05 06:16:23
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 quickly). My question is, lets say I had BufferedImage Screenshot and BufferedImage smallImage, how

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

做~自己de王妃 提交于 2019-12-05 03:43:16
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; import java.awt.GraphicsConfiguration; import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment;

Screen Capture in Java not capturing whole screen

烈酒焚心 提交于 2019-12-05 01:13:24
问题 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 external monitor - this code only takes a screen shot of my laptop screen, not the larger external monitor I'm working from - any ideas how to change the code? I'm running OSX in case that's relevant... import java.awt.AWTException; import java.awt.Robot

Is it possible to click on Windows UAC dialog using java.awt.Robot?

我怕爱的太早我们不能终老 提交于 2019-12-04 16:40:36
I'm working on a custom remote desktop in Java using java.awt.Robot on Windows 7. It all works apart from running a Command Prompt as an administrator. The UAC dialog appears, however button clicks are not accepted on the Yes button using mousePress() / mouseRelease() , neither are key presses with keyPress() / keyRelease() . The application is launched via a launch4j launcher in launcher rather than wrap mode. Things I've done so far Disabled secure desktop for UAC. This allowed the screen grabber part of the application to at least 'see' the prompt Changed group policy to disable

java.awt.Robot inside games?

时光怂恿深爱的人放手 提交于 2019-12-04 13:53:47
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.awt.event.KeyEvent; public class KeyStroke { public static void main(String[] args) throws

Java Robot mouse move: setting speed?

时光怂恿深爱的人放手 提交于 2019-12-04 12:30:29
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? The Robot class has a delay(...) method that you can use to control movement from point to point. Try a few

Get screen coordinates of a node in javaFX 8

故事扮演 提交于 2019-12-04 09:58:45
问题 I am developing a JavaFX application on Windows 8.1 64bit with 4GB of RAM with JDK version 8u45 64bit. I want to capture part of the screen using Robot but the problem is that I can't get the screen coordinates of the anchor pane that I want to capture and I don't want to use snapshot because the output quality is bad. Here is my code. I have seen the question in this link Getting the global coordinate of a Node in JavaFX and this one get real position of a node in javaFX and I tried every

java sending keystrokes using robot class

大城市里の小女人 提交于 2019-12-04 09:35:55
问题 I know it's possible to send keystrokes in java using Robot Class , but is there any way to specify the target process when it's already started ? 回答1: The Robot will send the keystrokes to whichever application window is on top. To send keystrokes to a specific target, you will want to set the target as the platform's foreground window first. Doing this may require native code such as that provided by JNI or (what I use) JNA. If you desire to send keystrokes to a background window, I believe