public static void click(int x, int y) throws AWTException{ Robot bot = new Robot(); bot.mouseMove(x, y); bot.mousePress(InputEvent.BUTTON1_MASK); bot.mouseRelease(InputEvent.BUTTON1_MASK); }
try { Robot robot = new Robot(); // Simulate a mouse click robot.mousePress(InputEvent.BUTTON1_MASK); robot.mouseRelease(InputEvent.BUTTON1_MASK); // Simulate a key press robot.keyPress(KeyEvent.VK_A); robot.keyRelease(KeyEvent.VK_A); } catch (AWTException e) { e.printStackTrace(); }
Robot bot = new Robot(); bot.mouseMove(10,10); bot.mousePress(InputEvent.BUTTON1_MASK); //add time between press and release or the input event system may //not think it is a click try{Thread.sleep(250);}catch(InterruptedException e){} bot.mouseRelease(InputEvent.BUTTON1_MASK);
try { Robot robot = new Robot(); // Simulate a mouse click robot.mousePress(InputEvent.BUTTON1_MASK); robot.mouseRelease(InputEvent.BUTTON1_MASK); // Simulate a key press robot.keyPress(KeyEvent.VK_SHIFT); robot.keyPress(KeyEvent.VK_TAB); robot.keyRelease(KeyEvent.VK_TAB); robot.keyRelease(KeyEvent.VK_SHIFT); } catch (AWTException e) { e.printStackTrace(); }
public static void doLeftMouseClick(Robot r, int x, int y) { r.mouseMove(x, y); r.mousePress(InputEvent.BUTTON1_MASK); r.mouseRelease(InputEvent.BUTTON1_MASK); r.mouseMove(x, y); if (nr == 1) r.mousePress(InputEvent.BUTTON1_MASK); else r.mouseRelease(InputEvent.BUTTON1_MASK);
public class Gater { public void moveToGate(){ Robot robot = new Robot (); Thread.sleep(2000); robot.mouseMove(262,105); Thread.sleep(500); robot.mousePress( InputEvent.BUTTON1_MASK ); robot.mouseRelease( InputEvent.BUTTON1_MASK ); Thread.sleep(5000); } }
@Override public void mouseClick(MasterMouseEvent mouseEvent){ final int mouseButton1 = mouseEvent.getMouseButton(); robot.mousePress(mouseButton1); robot.mouseRelease(mouseButton1); }
@Override public void mouseDragged(MasterMouseEvent mouseEvent, int[] site){ final int mouseButton1 = mouseEvent.getMouseButton(); robot.mousePress(mouseButton1); mouseMove(site); }
public void playback(java.awt.Robot awtRobot, double playbackSpeed) { awtRobot.mouseMove(x, y); awtRobot.mousePress(mouseButton.getInputEventMask()); }
Timer timer = new Timer(100, new ActionListener() { private final Robot robot = new Robot(); public void actionPerformed(ActionEvent evt) { robot.mousePress(1); robot.mouseRelease(1); robot.keyPress(KeyEvent.VK_A); } });
Thread.sleep(1000); Robot robot = new Robot(); robot.mouseMove(sX, sY); robot.mousePress(InputEvent.BUTTON1_MASK); robot.mouseMove(endX, endY); robot.mouseRelease(InputEvent.BUTTON1_MASK);
int b = InputEvent.getMaskForButton(MouseEvent.BUTTON1); //1024 int c = InputEvent.BUTTON1_MASK; //8 // works on mac Robot r = new Robot(); r.mouseMove(500, 500); r.mousePress(1024); r.mouseRelease(1024);
public static void click(int x, int y) throws AWTException{ Robot bot = new Robot(); bot.mouseMove(x, y); bot.mousePress(InputEvent.BUTTON1_MASK); bot.mouseRelease(InputEvent.BUTTON1_MASK); }
public static void mousePress(ActionContext actionContext){ Thing self = (Thing) actionContext.get("self"); java.awt.Robot robot = (java.awt.Robot) self.doAction("getRobot", actionContext); Integer buttons = (Integer) self.doAction("getButtons", actionContext); robot.mousePress(buttons); }
public class TestRobot { Robot ro; Image img; public TestRobot(){ ro.mouseMove(100, 200); // move mouse to specific point ro.mousePress(InputEvent.BUTTON1_MASK ); //mouse click ro.mouseRelease(InputEvent.BUTTON1_MASK ); // mouse release ro.keyPress(KeyEvent.VK_F1); //press F1 ro.keyRelease(KeyEvent.VK_F1); //release F1 img = ro.createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize())); // take screen shot } }
Robot robot = new Robot(); // press and hold CONTROL key robot.keyPress(KeyEvent.VK_CONTROL); // Left Click robot.mousePress(InputEvent.BUTTON1_MASK); robot.mouseRelease(InputEvent.BUTTON1_MASK); // release CONTROL key robot.keyRelease(KeyEvent.VK_CONTROL);
public void click(AbstractButton button, int millis) throws AWTException { Point p = button.getLocationOnScreen(); Robot r = new Robot(); r.mouseMove(p.x + button.getWidth() / 2, p.y + button.getHeight() / 2); r.mousePress(InputEvent.BUTTON1_MASK); try { Thread.sleep(millis); } catch (Exception e) {} r.mouseRelease(InputEvent.BUTTON1_MASK); }
Robot r = new Robot(); r.mouseMove(10, 50); r.mousePress(InputEvent.BUTTON1_MASK); r.mouseRelease(InputEvent.BUTTON1_MASK); r.keyPress(KeyEvent.VK_A); r.keyRelease(KeyEvent.VK_A);
Robot r = new Robot(); r.mouseMove(635, 210); // brings focus on login popup window, got location(x,y coordinates) from Mouse-Position chrome plugin // left-click mouse on the location r.mousePress(MouseEvent.BUTTON1_MASK); r.mouseRelease(MouseEvent.BUTTON1_MASK); //simulating Enter key press, this automatically clicks login and submits the form r.keyPress(KeyEvent.VK_ENTER); r.keyRelease(KeyEvent.VK_ENTER);
public static void mouseMoveAndClick(ActionContext actionContext){ Thing self = (Thing) actionContext.get("self"); java.awt.Robot robot = (java.awt.Robot) self.doAction("getRobot", actionContext); Point point = (Point) self.doAction("getPoint", actionContext); robot.mouseMove(point.x, point.y); Integer buttons = (Integer) self.doAction("getButtons", actionContext); robot.mousePress(buttons); robot.mouseRelease(buttons); }