private void showCaretIfPossible(@Nullable JTextComponent textComponent) { if (textComponent == null) { return; } showCaretOf(textComponent); robot.waitForIdle(); }
public void robotPoweredMouseDown() { mouseObject.mousePress(InputEvent.BUTTON1_DOWN_MASK); mouseObject.waitForIdle(); }
public void robotPoweredMouseUp() { mouseObject.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); mouseObject.waitForIdle(); }
public void robotPoweredMoveMouseToAbsoluteCoordinates(int xCoordinates, int yCoordinates) { mouseObject.mouseMove(xCoordinates, yCoordinates); mouseObject.waitForIdle(); }
@Override public void waitForIdle() { try { new java.awt.Robot().waitForIdle(); } catch (AWTException e) { Debug.log(-1, "Error-could non instantiate robot: " + e); } }
public static void waitForIdle(ActionContext actionContext){ Thing self = (Thing) actionContext.get("self"); java.awt.Robot robot = (java.awt.Robot) self.doAction("getRobot", actionContext); robot.waitForIdle(); }
public void robotPoweredClick() { mouseObject.mousePress(InputEvent.BUTTON1_DOWN_MASK); mouseObject.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); mouseObject.waitForIdle(); } }
static Robot robot=null; private void initialize(){ Thread hilo=new Thread(new Runnable(){ @Override public void run() { try { robot=new Robot(); robot.waitForIdle(); } catch (AWTException e) { // TODO Auto-generated catch block e.printStackTrace(); } }}); hilo.start(); }
@Nonnull private BufferedImage takeScreenshot(Rectangle r) { JTextComponent textComponent = findFocusOwnerAndHideItsCaret(); robot.waitForIdle(); try { return takeScreenshot(robot, r); } finally { showCaretIfPossible(textComponent); } }
import java.awt.Robot; public void disableScreenSaver() throws AWTException { Robot r = new Robot(); r.waitForIdle(); r.keyPress(KeyEvent.VK_CONTROL); r.keyRelease(KeyEvent.VK_CONTROL); }
MacroPlayer.this.robot.waitForIdle(); MacroPlayer.this.robot.waitForIdle();
@Override public void run() { try { Robot robot = new Robot(); while (!exit) { try { Thread.sleep(tickMillis); } catch (InterruptedException e) { // Ignore exception } long now = getClockMillis(); if (now - lastPowerTick < tickMillis) { if (Emulator.log.isTraceEnabled()) { Emulator.log.trace(String.format("Moving the mouse to disable the screen saver (PowerTick since %d ms)", now - lastPowerTick)); } robot.waitForIdle(); // Move the mouse to its current location to disable the screensaver PointerInfo mouseInfo = MouseInfo.getPointerInfo(); robot.mouseMove(mouseInfo.getLocation().x, mouseInfo.getLocation().y); } else { if (Emulator.log.isTraceEnabled()) { Emulator.log.trace(String.format("PowerTick not called since %d ms", now - lastPowerTick)); } } } } catch (AWTException e) { Emulator.log.error(e); } } }
robot.waitForIdle(); break;
robot.waitForIdle(); robot.keyRelease(KeyEvent.VK_F); robot.keyRelease(KeyEvent.VK_ALT); robot.waitForIdle(); } catch (AWTException exp) { exp.printStackTrace();
/** Exercise the GUI using the AWT Robot */ static void exercise(Frame f, Robot r) { r.delay(1000); // time for frame to become visible. log("Starting"); r.mouseMove(50,30); r.mousePress(InputEvent.BUTTON1_MASK); r.mouseRelease(InputEvent.BUTTON1_MASK); r.waitForIdle(); r.mouseMove(150,20); log("All done"); }
public void robotPoweredMoveMouseToCoordinatesOnPage(int xCoordinates, int yCoordinates) { //Get Browser dimensions int browserWidth = driver.manage().window().getSize().width; int browserHeight = driver.manage().window().getSize().height; //Get dimensions of the window displaying the web page int pageWidth = Integer.parseInt(executor.executeScript("return document.documentElement.clientWidth").toString()); int pageHeight = Integer.parseInt(executor.executeScript("return document.documentElement.clientHeight").toString()); //Calculate the space the browser is using for toolbars int browserFurnitureOffsetX = browserWidth - pageWidth; int browserFurnitureOffsetY = browserHeight - pageHeight; //Calculate the correct X/Y coordinates based upon the browser furniture offset and the position of the browser on the desktop int xPosition = driver.manage().window().getPosition().x + browserFurnitureOffsetX + xCoordinates; int yPosition = driver.manage().window().getPosition().y + browserFurnitureOffsetY + yCoordinates; //Move the mouse to the calculated X/Y coordinates mouseObject.mouseMove(xPosition, yPosition); mouseObject.waitForIdle(); }
public void robotPoweredMoveMouseToWebElementCoordinates(WebElement element) { //Get Browser dimensions int browserWidth = driver.manage().window().getSize().width; int browserHeight = driver.manage().window().getSize().height; //Get dimensions of the window displaying the web page int pageWidth = Integer.parseInt(executor.executeScript("return document.documentElement.clientWidth").toString()); int pageHeight = Integer.parseInt(executor.executeScript("return document.documentElement.clientHeight").toString()); //Calculate the space the browser is using for toolbars int browserFurnitureOffsetX = browserWidth - pageWidth; int browserFurnitureOffsetY = browserHeight - pageHeight; //Get the coordinates of the WebElement on the page and calculate the centre point int webElementX = ((Locatable) element).getCoordinates().inViewPort().x + Math.round(element.getSize().width / 2); int webElementY = ((Locatable) element).getCoordinates().inViewPort().y + Math.round(element.getSize().height / 2); //Calculate the correct X/Y coordinates based upon the browser furniture offset and the position of the browser on the desktop int xPosition = driver.manage().window().getPosition().x + browserFurnitureOffsetX + webElementX; int yPosition = driver.manage().window().getPosition().y + browserFurnitureOffsetY + webElementY; //Move the mouse to the calculated X/Y coordinates mouseObject.mouseMove(xPosition, yPosition); mouseObject.waitForIdle(); }
r.waitForIdle(); r.keyPress(KeyEvent.VK_T); r.keyRelease(KeyEvent.VK_T); r.keyPress(KeyEvent.VK_T); r.keyRelease(KeyEvent.VK_T);
w.setVisible(true); robot.waitForIdle(); WindowTracker tracker = WindowTracker.getTracker(); while (!tracker.isWindowReady(w)) {