awtrobot

Robot class java , typing a string issue

ⅰ亾dé卋堺 提交于 2021-02-05 06:11:46
问题 I m using the following loop , but its only typing the first charecter and the rest as numbers, any idea ? import java.awt.*; import javax.swing.KeyStroke; public class test { public static void main(String[] args) throws AWTException { Robot r = new Robot(); String s = "Face"; for (int i = 0; i < s.length(); i++) { char res = s.charAt(i); r.keyPress(res); r.keyRelease(res); r.delay(1000); } } } OUTPUT typing : F135 回答1: The keyPress/Release methods need an int value that represents the

How can I select text in another application with java.awt.robot (example: shift+home)

倾然丶 夕夏残阳落幕 提交于 2021-01-29 15:53:29
问题 I am trying to use java.awt.robot to fix some Excel arrays for me automatically. In order to do so, I need to select the text inside a cell. It seems that shift+home and shift+arrow keys do not work for selecting text. Here is a code snippet: import java.awt.AWTException; import java.awt.Robot; import java.awt.event.InputEvent; import java.awt.event.KeyEvent; public class Fix4DArray { public static void main(String[] args){ int n = 10; //nominal sleep time try { Robot r = new Robot();

How to bring browser to front using Selenium WebDriver?

孤人 提交于 2020-02-06 08:13:06
问题 I've a test where it handles login system popup using Robot of Java. But because of some issues, other applications or browser instance come to front and Robot could not perform actions on system popup of Windows. Hence before interacting with system popup using Robot , I want to bring that browser to front on machine. I tried following but it did not help - ((JavascriptExecutor)driver).executeScript("window.focus();"); Could you please suggest how I can bring it to the front? 来源: https:/

How to bring browser to front using Selenium WebDriver?

早过忘川 提交于 2020-02-06 08:12:06
问题 I've a test where it handles login system popup using Robot of Java. But because of some issues, other applications or browser instance come to front and Robot could not perform actions on system popup of Windows. Hence before interacting with system popup using Robot , I want to bring that browser to front on machine. I tried following but it did not help - ((JavascriptExecutor)driver).executeScript("window.focus();"); Could you please suggest how I can bring it to the front? 来源: https:/

Get the VK int from an arbitrary char in java

本小妞迷上赌 提交于 2020-01-29 03:52:07
问题 How do you get the VK code from a char that is a letter? It seems like you should be able to do something like javax.swing.KeyStroke.getKeyStroke('c').getKeyCode() , but that doesn't work (the result is zero). Everyone knows how to get the key code if you already have a KeyEvent, but what if you just want to turn chars into VK ints? I'm not interested in getting the FK code for strange characters, only [A-Z],[a-z],[0-9]. Context of this problem -------- All of the Robot tutorials I've seen

Java: use Robot while running fullscreen app

你说的曾经没有我的故事 提交于 2020-01-21 11:51:03
问题 I have a problem with Robot class in Java: it sometimes doesn't work when i run a fullscreen game. Here's my code: Toolkit tlkt = Toolkit.getDefaultToolkit(); Robot bot = new Robot(); while(true) { Thread.sleep(3000); tlkt.beep(); //make sure that program still runs bot.mousePress(MouseEvent.BUTTON1_DOWN_MASK); bot.mouseRelease(MouseEvent.BUTTON1_DOWN_MASK); } I want to left-click every 3 seconds and beep for sure. It work fine but when I run some full-screen application, then it just beeps

Java: use Robot while running fullscreen app

南笙酒味 提交于 2020-01-21 11:50:26
问题 I have a problem with Robot class in Java: it sometimes doesn't work when i run a fullscreen game. Here's my code: Toolkit tlkt = Toolkit.getDefaultToolkit(); Robot bot = new Robot(); while(true) { Thread.sleep(3000); tlkt.beep(); //make sure that program still runs bot.mousePress(MouseEvent.BUTTON1_DOWN_MASK); bot.mouseRelease(MouseEvent.BUTTON1_DOWN_MASK); } I want to left-click every 3 seconds and beep for sure. It work fine but when I run some full-screen application, then it just beeps

How to take a custom shaped screenshot?

笑着哭i 提交于 2020-01-14 05:46:30
问题 For creating screenshots in Java i have been using the java.awt.Robot class' createScreenCapture() method. But i was only able to create screenshots in the Rectangle shape. Now my question is is there any way to take a screenshot of custom shape either by using the Robot class or some other explicit code? And by the way, for custom shape the screenshot has to be transparent and i am likely to store it in PNG format. Any answer is appreciated. 回答1: is there any way to take a screenshot of

How to take a custom shaped screenshot?

回眸只為那壹抹淺笑 提交于 2020-01-14 05:45:07
问题 For creating screenshots in Java i have been using the java.awt.Robot class' createScreenCapture() method. But i was only able to create screenshots in the Rectangle shape. Now my question is is there any way to take a screenshot of custom shape either by using the Robot class or some other explicit code? And by the way, for custom shape the screenshot has to be transparent and i am likely to store it in PNG format. Any answer is appreciated. 回答1: is there any way to take a screenshot of

Java Robot Class Using Variables

二次信任 提交于 2020-01-05 08:37:35
问题 I have a very simple question, or at least I think it is simple. Currently I'm trying to use the robot class with variables. What I mean by this is the following (the variables "pass" are chars.) pass1 = 0; pass2 = 0; pass3 = 0; pass4 = 0; try{ Robot robot = new Robot(); robot.delay(2000); robot.mouseMove(1318, 322); robot.keyPress(pass1); robot.keyPress(pass2); robot.keyPress(pass3); robot.keyPress(pass4); } catch (AWTException e) {e.printStackTrace();} When I run the program, I get this