awtrobot

How to get the x and y of a program window in Java?

蓝咒 提交于 2019-11-26 08:47:49
Is there a way for me to get the X and Y values of a window in java? I read that I'll have to use runtime, since java can't mess directly, however I am not so sure of how to do this. Can anyone point me some links/tips on how to get this? To get the x and y position of "any other unrelated application" you're going to have to query the OS and that means likely using either JNI, JNA or some other scripting utility such as AutoIt (if Windows). I recommend either JNA or the scripting utility since both are much easier to use than JNI (in my limited experience), but to use them you'll need to

File Upload using Selenium WebDriver and Java Robot Class

六眼飞鱼酱① 提交于 2019-11-26 08:09:46
问题 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

Convert String to KeyEvents

≡放荡痞女 提交于 2019-11-26 03:22:54
问题 I want to convert a String into KeyEvent to do something like this : writeKeyboard(myBot,\"abcd\"); public void writeKeyboard(Robot bot, String st){ char[] arr = arr.toCharArray(); int i = arr.length(); int j = 0; int keycode; while (j<i) { keycode = arr[j].something; bot.keyPress(keycode); bot.keyRelease(keycode); j++; } } 回答1: I'm basically using a glorified switch statement. Simple and fast: import static java.awt.event.KeyEvent.*; public class Keyboard { private Robot robot; public static

How to get the x and y of a program window in Java?

[亡魂溺海] 提交于 2019-11-26 02:02:48
问题 Is there a way for me to get the X and Y values of a window in java? I read that I\'ll have to use runtime, since java can\'t mess directly, however I am not so sure of how to do this. Can anyone point me some links/tips on how to get this? 回答1: To get the x and y position of "any other unrelated application" you're going to have to query the OS and that means likely using either JNI, JNA or some other scripting utility such as AutoIt (if Windows). I recommend either JNA or the scripting

Convert String to KeyEvents

寵の児 提交于 2019-11-25 21:21:32
I want to convert a String into KeyEvent to do something like this : writeKeyboard(myBot,"abcd"); public void writeKeyboard(Robot bot, String st){ char[] arr = arr.toCharArray(); int i = arr.length(); int j = 0; int keycode; while (j<i) { keycode = arr[j].something; bot.keyPress(keycode); bot.keyRelease(keycode); j++; } } Adam Paynter I'm basically using a glorified switch statement. Simple and fast: import static java.awt.event.KeyEvent.*; public class Keyboard { private Robot robot; public static void main(String... args) throws Exception { Keyboard keyboard = new Keyboard(); keyboard.type(