awtrobot

Java awt.Robot not working inside a virtual machine?

≡放荡痞女 提交于 2019-12-03 23:13:43
问题 I'm trying to use the java.awt.Robot class for testing inside a virtual machine. Everything works as expected if I test it in my host computer, but when I run the same program inside a virtual machine, nothing happens and there is no error/exceptions. I have tried inside virtual machines running Windows XP or Windows 7 on different computers and it never worked. The code I used for testing on the machines was very simple: try { final Robot robot = new Robot(); robot.mouseMove(500, 500); }

Screen Capture in Java not capturing whole screen

对着背影说爱祢 提交于 2019-12-03 20:20:22
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; import java.awt.Rectangle; import java.awt.Toolkit; import java.awt.image.BufferedImage; import java

Java Robot Class - Add focus to a specific running Application?

↘锁芯ラ 提交于 2019-12-03 17:17:34
I am just trying to figure out if/how to get the Java Robot class to change focus from the running java app, to a specific process, such as ms word or firefox. Thanks! Robot can't do that automatically. You can activate another application via alt-tab as has been suggested above, but you'll need to know the z-order of the application that you want to activate. I think that to really do this best you'll want to get the window's handle (hWnd) of the top-level window that you want to activate (if this is a Windows app), and then using the Windows user32 library functions activate the desired

Get screen coordinates of a node in javaFX 8

流过昼夜 提交于 2019-12-03 03:42: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 answer but nothing is working, the image shows different parts of the screen. private void capturePane()

java sending keystrokes using robot class

时光总嘲笑我的痴心妄想 提交于 2019-12-03 03:28:26
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 ? 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 that you cannot use Robot, that you will have to write native code. Of course all native code solutions

how to open a save dialog popup in IE11 using Robot

帅比萌擦擦* 提交于 2019-12-02 07:47:47
问题 I am performing my testing on IE11 and can't use any other browser. While execution I am getting download pop up and want to download file in TestResult folder. How can I achieve this using Robot ? I have also read about AutoIT but not sure as I am quite new to these. Please tell me the easiest way. currently working on testng framework and stuck in download part. 来源: https://stackoverflow.com/questions/47092830/how-to-open-a-save-dialog-popup-in-ie11-using-robot

java.security.AccessControlException when using java.awt.Robot class for screen capture in applet

感情迁移 提交于 2019-12-02 06:42:39
问题 I require to capture a web page screen to store it on client's machine whenever client clicks print screen button. For this I googled and got that by embedding an applet with signature(trusted applet) in my jsp page i can do this. So I am trying with a simple applet for an standalone java class. On success I can try it for jsp after signing the applet. What I tried is: import java.applet.Applet; import java.awt.Graphics; import java.util.Date; import javax.imageio.ImageIO; import java.awt

java.security.AccessControlException when using java.awt.Robot class for screen capture in applet

扶醉桌前 提交于 2019-12-02 05:58:36
I require to capture a web page screen to store it on client's machine whenever client clicks print screen button. For this I googled and got that by embedding an applet with signature(trusted applet) in my jsp page i can do this. So I am trying with a simple applet for an standalone java class. On success I can try it for jsp after signing the applet. What I tried is: import java.applet.Applet; import java.awt.Graphics; import java.util.Date; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; import java.io.File; import java.awt.Dimension; import java.awt.Rectangle; import

java.awt.Robot.keyPress throws IllegalArgumentException when when pressing quotation mark key

痞子三分冷 提交于 2019-12-02 05:47:01
问题 When you try to use Robot.keyPress to type a " (double quotation mark) it throws a java.lang.IllegalArgumentException: Invalid key code. How can I fix or get around this? If it helps, I am currently on Windows. Test code: import java.awt.Robot; import java.awt.event.KeyEvent; public class Test { public static void main(String[] args) throws Exception { Robot robot = new Robot(); try { robot.keyPress(KeyEvent.VK_QUOTEDBL); } catch (Exception e) { e.printStackTrace(); } } } Exception: java.lang

Switching Apps on Mac with AWT Robot only sometimes works

99封情书 提交于 2019-12-02 04:35:22
I'm trying to use Robot in order to switch apps, and then enter some text. To do this (on my mac), I'm pressing Meta, Tab, and then releasing Tab, Meta in this order: Robot robot = new Robot(); robot.keyPress(KeyEvent.VK_META); robot.keyPress(KeyEvent.VK_TAB); robot.keyRelease(KeyEvent.VK_TAB); robot.keyRelease(KeyEvent.VK_META); This works, but only occasionally (about every 5 or six presses). I've tried calling Thread.wait() inbetween press and release, but this has no effect. Neither does trying to mask Tab with META_DOWN_MASK. I also tried using the JavaFX Robot (com.sun.glass.ui.Robot),