List of usage examples for java.awt Robot mouseRelease
public synchronized void mouseRelease(int buttons)
From source file:Main.java
public static void main(String[] argv) throws Exception { Robot robot = new Robot(); robot.mousePress(InputEvent.BUTTON1_MASK); robot.mouseRelease(InputEvent.BUTTON1_MASK); }
From source file:Main.java
public static void main(String[] args) throws Exception { Robot r = new Robot(); r.mouseMove(35, 35);// www.ja v a2 s. c o m r.mousePress(InputEvent.BUTTON1_MASK); r.mouseRelease(InputEvent.BUTTON1_MASK); Thread.sleep(50); r.mousePress(InputEvent.BUTTON1_MASK); r.mouseRelease(InputEvent.BUTTON1_MASK); }
From source file:Main.java
public static void main(String[] args) throws Exception { Robot r = new Robot(); r.mouseMove(35, 35);/* w ww . j a v a 2s .c o m*/ r.mousePress(InputEvent.BUTTON1_MASK); r.mouseRelease(InputEvent.BUTTON1_MASK); Thread.sleep(50); r.mousePress(InputEvent.BUTTON1_MASK); r.mouseRelease(InputEvent.BUTTON1_MASK); }
From source file:Main.java
public static void main(String[] args) throws Exception { Robot robot = new Robot(); robot.mouseMove(200, 200);/*w ww . j a v a2 s . c o m*/ robot.mousePress(InputEvent.BUTTON1_MASK); robot.mouseRelease(InputEvent.BUTTON1_MASK); robot.mouseWheel(-100); }
From source file:RobotTest.java
/** * Runs a sample test procedure//from w w w .j ava 2s. co m * * @param robot * the robot attached to the screen device */ public static void runTest(Robot robot) { // simulate a space bar press robot.keyPress(' '); robot.keyRelease(' '); // simulate a tab key followed by a space robot.delay(2000); robot.keyPress(KeyEvent.VK_TAB); robot.keyRelease(KeyEvent.VK_TAB); robot.keyPress(' '); robot.keyRelease(' '); // simulate a mouse click over the rightmost button robot.delay(2000); robot.mouseMove(200, 50); robot.mousePress(InputEvent.BUTTON1_MASK); robot.mouseRelease(InputEvent.BUTTON1_MASK); // capture the screen and show the resulting image robot.delay(2000); BufferedImage image = robot.createScreenCapture(new Rectangle(0, 0, 400, 300)); ImageFrame frame = new ImageFrame(image); frame.setVisible(true); }
From source file:com.seleniumtests.driver.CustomEventFiringWebDriver.java
/** * Left clic at coordinates on desktop. Coordinates are from screen point of view * @param x//www . j a v a 2 s. co m * @param y */ public static void leftClicOnDesktopAt(int x, int y, DriverMode driverMode, SeleniumGridConnector gridConnector) { if (driverMode == DriverMode.LOCAL) { try { Robot robot = new Robot(); moveMouse(robot, x, y); robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); } catch (AWTException e) { throw new ScenarioException("leftClicOnDesktopAt: problem using Robot: " + e.getMessage()); } } else if (driverMode == DriverMode.GRID && gridConnector != null) { gridConnector.leftClic(x, y); } else { throw new ScenarioException("driver supports leftClicOnDesktopAt only in local and grid mode"); } }
From source file:com.seleniumtests.driver.CustomEventFiringWebDriver.java
/** * right clic at coordinates on desktop. Coordinates are from screen point of view * @param x//from w w w .j av a 2 s .co m * @param y */ public static void rightClicOnDesktopAt(int x, int y, DriverMode driverMode, SeleniumGridConnector gridConnector) { if (driverMode == DriverMode.LOCAL) { try { Robot robot = new Robot(); moveMouse(robot, x, y); robot.mousePress(InputEvent.BUTTON2_DOWN_MASK); robot.mouseRelease(InputEvent.BUTTON2_DOWN_MASK); } catch (AWTException e) { throw new ScenarioException("rightClicOnDesktopAt: problem using Robot: " + e.getMessage()); } } else if (driverMode == DriverMode.GRID && gridConnector != null) { gridConnector.rightClic(x, y); } else { throw new ScenarioException("driver supports sendKeysToDesktop only in local and grid mode"); } }
From source file:com.seleniumtests.driver.CustomEventFiringWebDriver.java
/** * Left clic at coordinates on desktop. Coordinates are from screen point of view * @param x/*from w w w . j av a 2 s .c o m*/ * @param y */ public static void doubleClickOnDesktopAt(int x, int y, DriverMode driverMode, SeleniumGridConnector gridConnector) { if (driverMode == DriverMode.LOCAL) { try { Robot robot = new Robot(); moveMouse(robot, x, y); robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); robot.delay(10); robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); } catch (AWTException e) { throw new ScenarioException("doubleClickOnDesktopAt: problem using Robot: " + e.getMessage()); } } else if (driverMode == DriverMode.GRID && gridConnector != null) { gridConnector.doubleClick(x, y); } else { throw new ScenarioException("driver supports doubleClickOnDesktopAt only in local and grid mode"); } }
From source file:org.suren.autotest.web.framework.awt.AwtMouse.java
@Override public void click() { try {//from ww w . j a v a 2 s. co m Robot robot = new Robot(); robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); } catch (AWTException e) { e.printStackTrace(); } }
From source file:com.o2d.pkayjava.editor.Main.java
private void toggleVisible() { mainFrame.setVisible(!mainFrame.isVisible()); if (mainFrame.isVisible()) { mainFrame.toFront();/*from w w w .ja v a 2 s. c om*/ 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); } } }