awtrobot

How can I programmatically generate keypress events? [duplicate]

霸气de小男生 提交于 2019-11-27 22:59:08
This question already has an answer here: How to simulate keyboard presses in java? 1 answer What the java program should do is it should trigger keyboard press on some condition without a person pressing a keyboard key. So any program running in windows and in focus which requires keyboard input will get the input without a person actually pressing the keyboard. I found these related questions here : question 1 , question 2 I was wondering if there is any method to do this in Java. Use the Robot class. Code snippet: import java.awt.Robot; import java.awt.KeyEvent; Robot r = new Robot(); int

How do I read pixels from a PNG file?

随声附和 提交于 2019-11-27 14:27:00
I know how to capture a screenshot by using Robot, Windowtester or FEST. I also know how to read a pixel from the screen by using robot. int x = 10; int y = 10; Color px = getPixelColor(int x, int y); However, I don't know how to read a pixel from an image that is already captured. I'm planning to compare a current image, with an image from file. Lets say both are PNG. Are there any frameworks that I can use to compare images pixel by pixel? hughes Is this in Java? If so, you can use ImageIO.read( "yourImage.png" ) to get a BufferedImage . That will have a getData() method which will give you

Is there a Python equivalent to Java's AWT Robot class? [closed]

不羁岁月 提交于 2019-11-27 05:05:53
Does anyone know of a Python class similar to Java Robot ? Specifically I would like to perform a screen grab in Ubuntu, and eventually track mouse clicks and keyboard presses (although that's a slightly different question). If you have GTK, then you can use the gtk.gdk.Display class to do most of the work. It controls the keyboard/mouse pointer grabs a set of gtk.gdk.Screen objects. Check out GNU LDTP : GNU/Linux Desktop Testing Project (GNU LDTP) is aimed at producing high quality test automation framework [...] Especially Writing LDTP test scripts in Python scripting language Fred Larson As

How can I make Robot type a `:`?

試著忘記壹切 提交于 2019-11-27 04:49:53
问题 I want to type : using Java Robot. However, I'm getting an IllegalArgumentException . My code is: robot.keyPress(KeyEvent.VK_SHIFT); robot.keyPress(KeyEvent.VK_COLON); robot.keyRelease(KeyEvent.VK_COLON); robot.keyRelease(KeyEvent.VK_SHIFT); The exception is: java.lang.IllegalArgumentException: Invalid key code.]. I also tried with: robot.keyPress(KeyEvent.VK_SHIFT); robot.keyPress(KeyEvent.VK_SEMICOLON); robot.keyRelease(KeyEvent.VK_SEMICOLON); robot.keyRelease(KeyEvent.VK_SHIFT); How can I

How to move a mouse smoothly throughout the screen by using java?

不问归期 提交于 2019-11-27 02:59:04
问题 There is a mouseMove()method that makes the pointer jump to that location. I want to be able to make the mouse move smoothly throughout the screen. I need to write a method named mouseGLide() which takes a start x, start y, end x, end y, the total time the gliding should take, and the number of steps to make during the glide. It should animate the mouse pointer by moving from (start x, start y) to (end x, start y) in n steps. The total glide should take t milliseconds. I don't know how to get

Programmatically clicking a GUI button in Java Swing

六眼飞鱼酱① 提交于 2019-11-27 01:12:41
问题 How would I programmatically click a Swing JButton in a way that would register all the relevant action/mouse events and be visible to the user (i.e. they'd see the button being pressed as if they actually clicked it)? The button is in the same application I'm running; I'm not trying to control a button in another application. I suppose I could directly inject events into the queue, but I'd prefer to avoid that approach if possible, and doing it that way wouldn't show a visible click. I see

How can I programmatically generate keypress events? [duplicate]

社会主义新天地 提交于 2019-11-26 23:15:06
问题 This question already has an answer here : How to simulate keyboard presses in java? (1 answer) Closed 2 years ago . What the java program should do is it should trigger keyboard press on some condition without a person pressing a keyboard key. So any program running in windows and in focus which requires keyboard input will get the input without a person actually pressing the keyboard. I found these related questions here : question 1, question 2 I was wondering if there is any method to do

File Upload using Selenium WebDriver and Java Robot Class

帅比萌擦擦* 提交于 2019-11-26 22:02:52
I am using Selenium WebDriver and Java and I need to automate the file upload feature. I tried a lot, but the moment the Browse button is clicked and a new window opens the script stops executing further and rather getting stuck. I tried in both FireFox and IE driver but to no avail. I tried also by calling an autoit exe file, but as the new window opens on click of Browse button, the particular statement Runtime.getRuntime().exec("C:\\Selenium\\ImageUpload_FF.exe") couldn't be exeuted. Kindly help lisak This should work with Firefox, Chrome and IE drivers. FirefoxDriver driver = new

cannot instantiate a class using a button

删除回忆录丶 提交于 2019-11-26 21:42:56
问题 I am trying to make a screen capturing program. What I have is a transparent window, which will give the area to be captured, with a button capture on it, and I am trying to instantiate a class captureScreen that works good when captureScreen is individually executed using a command prompt I am trying to instantiate this captureScreen class when button capture is hit. I have tried keeping this class on my screenrecord.java , putting the code in event listener also. In both these cases,I get

Is there a Python equivalent to Java's AWT Robot class? [closed]

怎甘沉沦 提交于 2019-11-26 11:27:41
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . Does anyone know of a Python class similar to Java Robot? Specifically I would like to perform a screen grab in Ubuntu, and eventually track mouse clicks and keyboard presses (although that\'s a slightly different question). 回答1: If you have GTK, then you can use the gtk.gdk.Display class to do most of the work.