awtrobot

Do Robot methods need to be run on the event queue?

社会主义新天地 提交于 2019-12-17 16:33:50
问题 Robot is part of the AWT library, but it seems quite different from most all the rest of the library. I am creating a Swing GUI that mixes Swing with Java Native Access (JNA) and Robot to allow Java to drive some MS Windows/Citrix work programs. My gut feeling is that since Robot will queue events on the "platform's native input queue" that the last thing I want to do is to run it on the EDT, but on the other hand, most of the classes in the AWT and Swing libraries should be run on the Swing

simulate backspace key with java.awt.Robot

纵饮孤独 提交于 2019-12-17 14:58:30
问题 There seems to be an issue simulating the backspace key with java.awt.Robot . This thread seems to confirm this but it does not propose a solution. This works: Robot rob = new Robot(); rob.keyPress(KeyEvent.VK_A); rob.keyRelease(KeyEvent.VK_A); This doesn't: Robot rob = new Robot(); rob.keyPress(KeyEvent.VK_BACK_SPACE); rob.keyRelease(KeyEvent.VK_BACK_SPACE); Any ideas? 回答1: It seems to work in this test. Addendum: Regarding the cited article, "Aside from those keys that are defined by the

Java awt Robot still cant press non-numpad arrows on windows?

随声附和 提交于 2019-12-13 04:26:02
问题 This bug is known for years, yet is is still present in Java 1.7.0_25 version which I'm using on Windows 8. The following result are same regardless of wether i have numlock turned on or not: Robot bot = new Robot(); bot.keyPress(KeyEvent.VK_UP); //this in documentation is non-numpad up arrow key bot.keyRelease(KeyEvent.VK_UP); //pressed the numpad up arrow key //folowing line is line #43 bot.keyPress(KeyEvent.VK_KP_UP); //this in documentation is numpad up arrow key bot.keyRelease(KeyEvent

java.awt.Robot is not functioning as expected

空扰寡人 提交于 2019-12-13 03:39:30
问题 I have the following code: autoPlay = new Robot(); autoPlay.setAutoDelay(500); autoPlay.mouseMove((game.getLocationOnScreen().x + 1), (game.getLocationOnScreen().y + 1)); autoPlay.mousePress(InputEvent.BUTTON1_DOWN_MASK); autoPlay.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); autoPlay.mouseMove((game.getLocationOnScreen().x + 381), (game.getLocationOnScreen().y + 1)); autoPlay.mousePress(InputEvent.BUTTON1_DOWN_MASK); autoPlay.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); autoPlay.mouseMove((game

Java input method for Virtual Keyboard

巧了我就是萌 提交于 2019-12-13 03:39:17
问题 I am facing a problem in implementing Input method for Virtual Keyboard. Currently I am using robot class for sending input to any application from virtual keyboard. But for that I need to create mapping of key-code and unicode, which is not consistent on different keyboard layout, can I directly pass the UNICODE to any application using Input method without worry about mapping between keycode and unicode. Any useful link or sample code will be useful. It is a simple Java program which is

robot class mouseWheel not working

丶灬走出姿态 提交于 2019-12-13 02:27:02
问题 I have been working with simulating mouse events with the Robot class for a while, and all was well, until I tried to scroll using the mouseWheel function. I just have this simple line: Robot robot = new Robot(); robot.mouseWheel(-100); I have been trying variations of this for a long time, and the program runs, does nothing, then terminates normally. Can someone shed light on why this is? Thanks! 回答1: Your program might not be working because either there is nothing to scroll up on the GUI

Java- screen capture behind the application

亡梦爱人 提交于 2019-12-13 02:02:34
问题 Is there a way to capture the screen but without the app itself getting shown. I know how to minimize or make a frame invisible but this has to be done real fast cos it's going to happen alot in each second (at least once every second). I want it to look something like the magnifier in Windows Vista/7. (The app can see behind itself.) 回答1: This is not possible in Java without tight native integration with the window-manager of the platform in question. 回答2: Call setVisible(false) on your main

Using Selenium + Java robot + Scrapbook to download a complete web page

余生长醉 提交于 2019-12-13 00:56:56
问题 I'm trying to download a complete web page (including images, css, scipts, etc.) via Selenium, the java robot class and the ScrapBook firefox extension. I first tried the CTRL+S method with robot but doesn't worked because that could not press ENTER. So I decided to install ScrapBook on firefox (there's a method which do not displays the download dialog) and tried it with plain robot class, that worked fine. But I need to use it with selenium for rapid testing. So here is the source code:

Prevent robot.mouseMove to generate a MouseEvent?

自闭症网瘾萝莉.ら 提交于 2019-12-12 19:33:37
问题 I have a 3D game, and every time I move the cursor, I want it to reset to the middle. Problem is that robot.mouseMove() calls MouseEvent (It does make sense) and resets the position and so I can't rotate. Thank you! 回答1: Because Robot is generating a native event, the event will (eventually) make it's way to the Event Queue for processing by the EDT. This means if you try and do something like... removeMouseListener(...); Robot.mouseMove(...); addMouseListener(...); It will, basically, have

Tracking OS-level window events in Java

女生的网名这么多〃 提交于 2019-12-12 19:17:08
问题 I have a requirement to be able to track how much a user interacts with the different applications running on their machine. What seemed logical to me was to keep a log of window focus events with timestamps which would tell you what applications were in focus over the course of the day. We have some other things to do in this application that would be straightforward in Java. However I haven't done any GUI programming in Java so I'm not sure if it's possible to get information about OS-level