Example usage for java.awt Robot Robot

List of usage examples for java.awt Robot Robot

Introduction

In this page you can find the example usage for java.awt Robot Robot.

Prototype

public Robot() throws AWTException 

Source Link

Document

Constructs a Robot object in the coordinate system of the primary screen.

Usage

From source file:com.ixxus.IxxusAbstractTest.java

public void saveOsScreenShot(String methodName) throws IOException, AWTException {
    Robot robot = new Robot();
    BufferedImage screenShot = robot
            .createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));
    ImageIO.write(screenShot, "png", new File("target/webdriver-" + methodName + "_OS" + ".png"));
}

From source file:com.fanniemae.ezpie.actions.HighlightScan.java

private void changeOracleExtractExtension(File castExtractionFile) {
    ProcessBuilder pb = new ProcessBuilder("java", "-jar", _dbDeliveryToolPath);
    Process process = null;/* www  . java 2 s.  c  o m*/
    Robot robot = null;
    try {
        process = pb.start();
        robot = new Robot();
    } catch (IOException | AWTException e) {
        throw new PieException("Could not start Oracle extract.", e);
    }

    sleep(15000);
    // navigating to input text
    for (int i = 0; i < 3; i++) {
        keyPressRelease(KeyEvent.VK_TAB, 200);
        sleep(200);
    }

    // select populated target folder path
    keyPressReleaseControlA(500);

    // entering target folder path
    Keyboard keyboard = new Keyboard(robot);
    keyboard.type(castExtractionFile.getParent() + "\\deliveryResults");

    // navigate to options
    keyPressReleaseShiftTab(200);
    keyPressRelease(KeyEvent.VK_RIGHT, 500);
    for (int i = 0; i < 2; i++) {
        keyPressRelease(KeyEvent.VK_TAB, 200);
        sleep(200);
    }

    // select populated extraction file path
    keyPressReleaseControlA(500);

    // entering target folder path that contains .castextraction file
    keyboard.type(castExtractionFile.getPath());
    sleep(500);
    keyPressRelease(KeyEvent.VK_TAB, 200);
    sleep(500);

    // navigate to menu bar to select Application/Run Application since tabbing to 'Run Application' button
    // and pressing enter does not execute run
    keyPressRelease(KeyEvent.VK_ALT, 500);
    sleep(500);
    for (int i = 0; i < 2; i++) {
        keyPressRelease(KeyEvent.VK_RIGHT, 200);
    }
    keyPressRelease(KeyEvent.VK_ENTER, 200);
    keyPressRelease(KeyEvent.VK_DOWN, 500);
    keyPressRelease(KeyEvent.VK_ENTER, 200);

    sleep(5000);
    process.destroy();
}

From source file:com.thoughtworks.selenium.SeleneseTestNgHelperVir.java

/**
 * Read run prop./* www  .  j  a v  a2 s .c  om*/
 * 
 * @throws Exception
 *             Signals that an I/O exception has occurred.
 */
@BeforeSuite
public final void readRunProp() throws Exception {

    // Initializing the logger
    initLogger();
    initReporter();
    resultReporter.addNewTestExecution();
    getLogger(SeleneseTestNgHelperVir.class);

    setRobot(new Robot());

    setProp(new Properties());
    String rootFile = new File("").getAbsolutePath();
    String file = "";
    if (rootFile.indexOf("grid") > -1) {
        file = rootFile + File.separator + "grid" + File.separator + "selenium-grid-1.0.6" + File.separator
                + "project.properties";

    } else {
        file = rootFile + File.separator + "project.properties";
    }
    setPropertiesLocation(file);
    getLog().info("Propery file location : " + rootFile);
    this.readUserProp();
}

From source file:com.o2d.pkayjava.editor.Main.java

private void toggleVisible() {
    mainFrame.setVisible(!mainFrame.isVisible());
    if (mainFrame.isVisible()) {
        mainFrame.toFront();//from  ww  w.  j av  a 2s.c o  m
        mainFrame.requestFocus();
        mainFrame.setAlwaysOnTop(true);
        try {
            //remember the last location of mouse
            final Point oldMouseLocation = MouseInfo.getPointerInfo().getLocation();

            //simulate a mouse click on title bar of window
            Robot robot = new Robot();
            robot.mouseMove(mainFrame.getX() + 100, mainFrame.getY() + 5);
            robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
            robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);

            //move mouse to old location
            robot.mouseMove((int) oldMouseLocation.getX(), (int) oldMouseLocation.getY());
        } catch (Exception ex) {
            //just ignore exception, or you can handle it as you want
        } finally {
            mainFrame.setAlwaysOnTop(false);
        }
    }
}

From source file:com.artistech.tuio.mouse.MouseDriver.java

/**
 * Constructor.
 *
 * @throws AWTException
 */
public MouseDriver() throws AWTException {
    robot = new Robot();
}

From source file:org.openecomp.sdc.ci.tests.utilities.ResourceUIUtils.java

public static void scrollDownPage() throws AWTException, InterruptedException {
    Robot robot = new Robot();
    robot.keyPress(KeyEvent.VK_PAGE_DOWN);
    robot.keyRelease(KeyEvent.VK_PAGE_DOWN);
    robot.keyPress(KeyEvent.VK_PAGE_DOWN);
    robot.keyRelease(KeyEvent.VK_PAGE_DOWN);
    robot.keyPress(KeyEvent.VK_PAGE_DOWN);
    robot.keyRelease(KeyEvent.VK_PAGE_DOWN);
    robot.keyPress(KeyEvent.VK_PAGE_DOWN);
    robot.keyRelease(KeyEvent.VK_PAGE_DOWN);
    robot.keyPress(KeyEvent.VK_PAGE_DOWN);
    robot.keyRelease(KeyEvent.VK_PAGE_DOWN);
    robot.keyPress(KeyEvent.VK_PAGE_DOWN);
    robot.keyRelease(KeyEvent.VK_PAGE_DOWN);
    robot.keyPress(KeyEvent.VK_PAGE_DOWN);
    robot.keyRelease(KeyEvent.VK_PAGE_DOWN);
}

From source file:com.ubershy.streamsis.actions.HotkeyAction.java

private Robot getRobot() {
    Robot beepboopbeep = null;/*  ww  w. j a  v  a2  s . co m*/
    try {
        beepboopbeep = new Robot();
    } catch (AWTException e) {
        String error = "Can't initialize Robot for hotkeys";
        logger.error(error, e);
        throw new RuntimeException(error); // lets just crash if something like that happens
    }
    return beepboopbeep;
}

From source file:com.grillecube.editor.ModelEditor.java

private void useRobot() {
    try {/*from   w ww .ja  va  2 s . c o m*/
        this._robot = new Robot();
        this._engine.getRenderer().getGLFWWindow().addMouseEnterListener(this);
        this._engine.getRenderer().getGLFWWindow().addMouseExitListener(this);
    } catch (AWTException e) {
        Logger.get().log(Level.WARNING, "Tried to a use Robot but it failed: ModelWindow.useRobot()");
        e.printStackTrace(Logger.get().getPrintStream());
    }
}

From source file:jp.co.heppokoact.autocapture.FXMLDocumentController.java

@Override
public void initialize(URL url, ResourceBundle rb) {
    // ???/*w ww .  ja va  2  s . co  m*/
    prop = new Properties();
    if (CONFIG_FILE.exists()) {
        try (InputStream in = new FileInputStream(CONFIG_FILE)) {
            prop.loadFromXML(in);
        } catch (IOException e) {
            throw new RuntimeException("????????", e);
        }
    }

    // ????????
    String saveDirectoryPath = prop.getProperty("saveDirectoryPath");
    if (saveDirectoryPath != null) {
        File tempSaveDirectory = new File(saveDirectoryPath);
        if (tempSaveDirectory.exists()) {
            saveDirectory.set(tempSaveDirectory);
        }
    }

    // ???
    saveDirectoryLabel.textProperty().bind(Bindings.createStringBinding(() -> {
        File sd = saveDirectory.get();
        return (sd == null) ? "" : sd.getName();
    }, saveDirectory));
    areaStartXLabel.textProperty().bind(Bindings.convert(areaStartX));
    areaStartYLabel.textProperty().bind(Bindings.convert(areaStartY));
    areaEndXLabel.textProperty().bind(Bindings.convert(areaEndX));
    areaEndYLabel.textProperty().bind(Bindings.convert(areaEndY));
    nextPointXLabel.textProperty().bind(Bindings.convert(nextPointX));
    nextPointYLabel.textProperty().bind(Bindings.convert(nextPointY));
    prevPointXLabel.textProperty().bind(Bindings.convert(prevPointX));
    prevPointYLabel.textProperty().bind(Bindings.convert(prevPointY));

    // ???
    stopButton.setDisable(true);

    // ????
    captureService = new CaptureService();
    captureTimeline = new Timeline(new KeyFrame(new Duration(CAPTURE_INTERVAL), e -> {
        captureService.restart();
    }));
    captureTimeline.setCycleCount(Timeline.INDEFINITE);
    try {
        robot = new Robot();
    } catch (AWTException e) {
        throw new RuntimeException("???????", e);
    }

    // ??
    clip = new AudioClip(ClassLoader.getSystemResource("ayashi.wav").toString());
}

From source file:org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils.java

public static void scrollDown() throws AWTException {
    Robot robot = new Robot();
    robot.keyPress(KeyEvent.VK_DOWN);
    robot.keyRelease(KeyEvent.VK_DOWN);
}