awtrobot

Is there a way to stop the Robot class after it has started

帅比萌擦擦* 提交于 2021-02-20 02:49:53
问题 Is there a way to stop Java Robot execution once it's started? I have a program that simulates left mouse button clicks, but i also have an unused JButton named STOP that was supposed to stop this clicking that i started using the Robot class. I noticed that Robot is fairly harder than the Thread class. Any ideas? import java.awt.AWTException; import java.awt.Robot; import java.awt.event.InputEvent; import java.util.Random; public class Click{ Robot robot = new Robot(); private void leftClick

Make a “Fake” mouse in java?

一世执手 提交于 2021-02-18 11:41:16
问题 In java you can use the Robot Class to move the mouse and fire mouse clicks. While this is cool, it also "hijacks" the users mouse, so you cannot multitask. What I want to do is make a "Fake" mouse that acts independently of the system's mouse cursor, and lives only inside my java applet. In this sense the applet would think it was being clicked by the mouse in various (x,y) positions (within the applet), however I can do whatever I want with the system mouse and it will not be affected. I

Key pressing special characters using Robot class Java

拟墨画扇 提交于 2021-02-11 15:39:31
问题 I am writing a program that simply retypes the text from the data file. The program works until it hits its first special character. Here is an example: data file Hey what is up? what i get Hey what is up (throws illegal argument exception) Here is my code: public static void KeyPresser() throws FileNotFoundException, AWTException { Robot robot = new Robot(); Scanner file = new Scanner(new File("script.dat")); while(file.hasNext()) { String word = file.nextLine(); for(int i = 0;i<word.length(

Key pressing special characters using Robot class Java

十年热恋 提交于 2021-02-11 15:38:27
问题 I am writing a program that simply retypes the text from the data file. The program works until it hits its first special character. Here is an example: data file Hey what is up? what i get Hey what is up (throws illegal argument exception) Here is my code: public static void KeyPresser() throws FileNotFoundException, AWTException { Robot robot = new Robot(); Scanner file = new Scanner(new File("script.dat")); while(file.hasNext()) { String word = file.nextLine(); for(int i = 0;i<word.length(

run function on JButton press

混江龙づ霸主 提交于 2021-02-09 12:21:54
问题 I'm attempting to make a program in java that uses a robot to press a specific key every few seconds. It has a GUI with a start and stop button and a label which tells which state its in. I've got everything working so far except that when I click "start" it runs the loop for my robot function (which is infinite) it doesn't enable the stop button like I thought it would. I know its something stupid with where the infinite loop is placed but I'm not sure how to make it work correctly. I don't

run function on JButton press

倾然丶 夕夏残阳落幕 提交于 2021-02-09 12:21:51
问题 I'm attempting to make a program in java that uses a robot to press a specific key every few seconds. It has a GUI with a start and stop button and a label which tells which state its in. I've got everything working so far except that when I click "start" it runs the loop for my robot function (which is infinite) it doesn't enable the stop button like I thought it would. I know its something stupid with where the infinite loop is placed but I'm not sure how to make it work correctly. I don't

How to capture only a desired portion of screen using createScreenCapture

强颜欢笑 提交于 2021-02-08 14:11:58
问题 The following code captures the screen: import java.awt.Dimension; import java.awt.Rectangle; import java.awt.Robot; import java.awt.Toolkit; import java.awt.image.BufferedImage; public class capture{ public static void main(String args[]) { try { Dimension size = Toolkit.getDefaultToolkit().getScreenSize(); Robot robot = new Robot(); BufferedImage img = robot.createScreenCapture(new Rectangle(size)); } catch(Exception e) { } } } Is there a way, to capture only a desired portion of the screen

Java robot not working

戏子无情 提交于 2021-02-05 08:28:30
问题 I am working on a simple speech recognition project. I have a command called scroll up where I want to use the class to press the UP key. This is the code: else if(resultText.equalsIgnoreCase("scroll up")) { try { Robot robot = new Robot(); robot.delay(5000); robot.keyPress(KeyEvent.VK_UP); robot.delay(1000); robot.keyPress(KeyEvent.VK_UP); robot.delay(1000); robot.keyPress(KeyEvent.VK_UP); } catch (AWTException e){ e.printStackTrace(); } } I have already imported these import java.awt

Java robot not working

亡梦爱人 提交于 2021-02-05 08:28:06
问题 I am working on a simple speech recognition project. I have a command called scroll up where I want to use the class to press the UP key. This is the code: else if(resultText.equalsIgnoreCase("scroll up")) { try { Robot robot = new Robot(); robot.delay(5000); robot.keyPress(KeyEvent.VK_UP); robot.delay(1000); robot.keyPress(KeyEvent.VK_UP); robot.delay(1000); robot.keyPress(KeyEvent.VK_UP); } catch (AWTException e){ e.printStackTrace(); } } I have already imported these import java.awt