public Robot getRobot(){ if(robot==null) try { robot = new Robot(); } catch (AWTException e) { throw new RuntimeException(e); } robot.setAutoWaitForIdle(true); return robot; }
private static java.awt.Robot getRobot() { if (myRobot == null) { try { myRobot = new java.awt.Robot(); } catch (Exception e) { return null; } myRobot.setAutoWaitForIdle(true); } return myRobot; }
public static void setAutoWaitForIdle(ActionContext actionContext){ Thing self = (Thing) actionContext.get("self"); java.awt.Robot robot = (java.awt.Robot) self.doAction("getRobot", actionContext); Boolean isOn = (Boolean) self.doAction("getIsOn", actionContext); robot.setAutoWaitForIdle(isOn); }
robot = new Robot(); robot.setAutoDelay(5); robot.setAutoWaitForIdle(true); } catch (AWTException e) { e.printStackTrace();
robot = new Robot(); robot.setAutoDelay(0); robot.setAutoWaitForIdle(false); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); width = screenSize.getWidth();
public void replay(Scenario scenario) { //component.requestFocusInWindow(); getRobot().setAutoWaitForIdle(false); start(); while(scenario.getEvents().size()>0){ Iterator<IEventLog> events = scenario.getEvents().iterator(); while(events.hasNext()){ IEventLog event = events.next(); if(elapsedMs(event)){ if(!mute) replay(event); //debug(event); events.remove(); } if(mustStop){ scenario.info("done replay after " + elapsedMs()/1000 + " s"); scenario.info("exiting before end"); return; } } } scenario.info("done replay after " + elapsedMs()/1000 + " s"); /*for(IEventLog event: scenario.getEvents()){ replay(event); }*/ }
import java.awt.AWTException; import java.awt.Robot; import static java.awt.event.KeyEvent.VK_ALT; import static java.awt.event.KeyEvent.VK_TAB; import static java.lang.Integer.parseInt; public class WindowSwitcher { public static void main(final String... args) throws AWTException { final int repeat = args.length != 0 ? parseInt(args[0]) : 1; final Robot robot = createRobot(); robot.keyPress(VK_ALT); for (int i = 0; i < repeat; i++) { robot.keyPress(VK_TAB); robot.keyRelease(VK_TAB); robot.delay(500); } robot.keyRelease(VK_ALT); } public static Robot createRobot() throws AWTException { final Robot robot = new Robot(); robot.setAutoWaitForIdle(true); robot.setAutoDelay(10); return robot; } }
return; r.setAutoWaitForIdle(true); r.delay(150); r.waitForIdle();
robot.setAutoWaitForIdle(true);