/** * Runs a sample test procedure * * @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); }
/** @param model File upload in IE browser. */ public void fileUploadinIE(MethodParameters model) { model.getElement().get(0).click(); StringSelection ss = new StringSelection(model.getData()); Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, null); Robot r; try { r = new Robot(); r.keyPress(KeyEvent.VK_ENTER); r.keyRelease(KeyEvent.VK_ENTER); r.keyPress(KeyEvent.VK_CONTROL); r.keyPress(KeyEvent.VK_V); r.keyRelease(KeyEvent.VK_V); r.keyRelease(KeyEvent.VK_CONTROL); r.keyPress(KeyEvent.VK_ENTER); r.keyRelease(KeyEvent.VK_ENTER); } catch (AWTException e) { MainTestNG.LOGGER.severe(e.getMessage()); } }
public static void main(final String[] args) throws AWTException { final boolean dump = Boolean.parseBoolean(args[0]); final Window w = new Frame() { @Override public void list(final PrintStream out, final int indent) { super.list(out, indent); dumped = true; } }; w.setSize(200, 200); w.setLocationRelativeTo(null); w.setVisible(true); final Robot robot = new Robot(); robot.setAutoDelay(50); robot.setAutoWaitForIdle(true); robot.mouseMove(w.getX() + w.getWidth() / 2, w.getY() + w.getHeight() / 2); robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); robot.keyPress(KeyEvent.VK_CONTROL); robot.keyPress(KeyEvent.VK_SHIFT); robot.keyPress(KeyEvent.VK_F1); robot.keyRelease(KeyEvent.VK_F1); robot.keyRelease(KeyEvent.VK_SHIFT); robot.keyRelease(KeyEvent.VK_CONTROL); w.dispose(); if (dumped != dump) { throw new RuntimeException("Exp:" + dump + ", actual:" + dumped); } }
private static void openweb() throws InterruptedException, AWTException { Robot robot = new Robot(); Thread.sleep(5000); String url = "http://www.freeproxylists.net/zh/?page="; Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard(); for (int i = 2; i <= 50; ++i) { String tUrl = url + Integer.toString(i); Transferable t = new StringSelection(tUrl); cb.setContents(t, null); robot.keyPress(KeyEvent.VK_CONTROL); robot.keyPress(KeyEvent.VK_T); robot.keyRelease(KeyEvent.VK_CONTROL); robot.keyRelease(KeyEvent.VK_T); Thread.sleep(1000); robot.keyPress(KeyEvent.VK_CONTROL); robot.keyPress(KeyEvent.VK_V); robot.keyRelease(KeyEvent.VK_CONTROL); robot.keyRelease(KeyEvent.VK_V); Thread.sleep(1000); robot.keyPress(KeyEvent.VK_ENTER); robot.keyRelease(KeyEvent.VK_ENTER); Thread.sleep(1000); } }
public static void ctrlR() { robot.keyPress(KeyEvent.VK_CONTROL); robot.keyPress(KeyEvent.VK_R); robot.delay(100); robot.keyRelease(KeyEvent.VK_R); robot.keyRelease(KeyEvent.VK_CONTROL); }
private void takeSnapshot() { robot.keyPress(KeyEvent.VK_ALT); robot.keyPress(KeyEvent.VK_PRINTSCREEN); robot.delay(40); robot.keyRelease(KeyEvent.VK_ALT); robot.keyRelease(KeyEvent.VK_PRINTSCREEN); robot.delay(40); }
public void start() { menu.setMnemonic('f'); submenu.setMnemonic('m'); menu.add(submenu); submenu.add(item); bar.add(menu); frame.setJMenuBar(bar); frame.pack(); item.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { Sysout.println(e.toString()); synchronized (activated) { activated.set(true); activated.notifyAll(); } } }); frame.setVisible(true); Util.waitForIdle(robot); boolean isMacOSX = (OSInfo.getOSType() == OSInfo.OSType.MACOSX); if (isMacOSX) { robot.keyPress(KeyEvent.VK_CONTROL); robot.delay(20); } robot.keyPress(KeyEvent.VK_ALT); robot.delay(20); robot.keyPress(KeyEvent.VK_F); robot.delay(20); robot.keyRelease(KeyEvent.VK_F); robot.delay(20); robot.keyRelease(KeyEvent.VK_ALT); if (isMacOSX) { robot.keyRelease(KeyEvent.VK_CONTROL); robot.delay(20); } Util.waitForIdle(robot); robot.keyPress(KeyEvent.VK_M); robot.delay(20); robot.keyRelease(KeyEvent.VK_M); Util.waitForIdle(robot); robot.keyPress(KeyEvent.VK_SPACE); robot.delay(20); robot.keyRelease(KeyEvent.VK_SPACE); Util.waitForIdle(robot); if (!Util.waitForCondition(activated, 2000)) { throw new TestFailedException("a submenu wasn't activated by mnemonic key press"); } Sysout.println("Test passed."); }
public static void main(String[] args) throws Exception { robot = new Robot(); robot.setAutoDelay(50); try { SwingUtilities.invokeAndWait( new Runnable() { @Override public void run() { createAndShowGUI(); } }); robot.waitForIdle(); checkFocusOwner(textField); robot.keyPress(KeyEvent.VK_TAB); robot.keyRelease(KeyEvent.VK_TAB); robot.waitForIdle(); checkFocusOwner(button); robot.keyPress(KeyEvent.VK_SHIFT); robot.keyPress(KeyEvent.VK_TAB); robot.keyRelease(KeyEvent.VK_TAB); robot.keyRelease(KeyEvent.VK_SHIFT); robot.waitForIdle(); checkFocusOwner(textField); robot.keyPress(KeyEvent.VK_SHIFT); robot.keyPress(KeyEvent.VK_TAB); robot.keyRelease(KeyEvent.VK_TAB); robot.keyRelease(KeyEvent.VK_SHIFT); robot.waitForIdle(); checkFocusOwner(button); } finally { SwingUtilities.invokeLater( new Runnable() { @Override public void run() { if (frame != null) { frame.dispose(); } } }); } System.out.println("Test Passed!"); }
/** * 将指定字符串设为剪切板的内容,然后执行粘贴操作 将页面焦点切换到输入框后,将指定内容粘贴到输入框中 * * @param string */ public static void setAndctrlVClipboardData(String string) { StringSelection stringSelection = new StringSelection(string); Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stringSelection, null); Robot robot = null; try { robot = new Robot(); } catch (AWTException e) { // TODO Auto-generated catch block e.printStackTrace(); } robot.keyPress(KeyEvent.VK_CONTROL); robot.keyPress(KeyEvent.VK_V); robot.keyRelease(KeyEvent.VK_V); robot.keyRelease(KeyEvent.VK_CONTROL); }
@Override public void operate(Robot robot) { try { robot.keyPress(getKeyField().getInt(null)); } catch (IllegalAccessException e) { e.printStackTrace(); } }
private void doType(int[] keyCodes, int offset, int length) { if (length == 0) { return; } robot.keyPress(keyCodes[offset]); doType(keyCodes, offset + 1, length - 1); robot.keyRelease(keyCodes[offset]); }
private void _doKeyPress(int keyCode) { if (keyCode != 0) { boolean modifierCheckEnabled = _testMouseListener.modifierCheckEnabled(); _testMouseListener.setModifierCheckEnabled(false); _robot.keyPress(keyCode); _robot.delay(MS_ROBOT_KEY_PRESS_DELAY); _testMouseListener.setModifierCheckEnabled(modifierCheckEnabled); } }
/** Provide password for window authentication */ public static void windowAuthenticationPassword(MethodParameters model) { Robot robot; try { robot = new Robot(); robot.keyPress(KeyEvent.VK_TAB); String letter = model.getData(); for (int i = 0; i < letter.length(); i++) { boolean upperCase = Character.isUpperCase(letter.charAt(i)); String KeyVal = Character.toString(letter.charAt(i)); String variableName = "VK_" + KeyVal.toUpperCase(); Class clazz = KeyEvent.class; Field field = clazz.getField(variableName); int keyCode = field.getInt(null); if (upperCase) { robot.keyPress(KeyEvent.VK_SHIFT); } robot.keyPress(keyCode); robot.keyRelease(keyCode); if (upperCase) { robot.keyRelease(KeyEvent.VK_SHIFT); } } robot.keyPress(KeyEvent.VK_ENTER); } catch (AWTException e) { MainTestNG.LOGGER.severe(e.getMessage()); } catch (NoSuchFieldException e) { MainTestNG.LOGGER.severe(e.getMessage()); } catch (SecurityException e) { MainTestNG.LOGGER.severe(e.getMessage()); } catch (IllegalArgumentException e) { MainTestNG.LOGGER.severe(e.getMessage()); } catch (IllegalAccessException e) { MainTestNG.LOGGER.severe(e.getMessage()); } }
/** * This method press the "A" key. Therefore it uses the <CODE>Robot</CODE> class. * * @see java.awt.Robot */ private void keyIntoDoc() { try { Robot rob = new Robot(); log.println("try to press 'A'"); rob.keyPress(java.awt.event.KeyEvent.VK_A); rob.keyRelease(java.awt.event.KeyEvent.VK_A); } catch (java.awt.AWTException e) { log.println("couldn't press key"); } }
/// COMPLETAMENTE INUTILE public static void downloadData(String url) { try { File file = new File("/home/leonardo/Scrivania/skyscann/"); FileUtils.cleanDirectory(file); Runtime runtime = Runtime.getRuntime(); runtime.exec("/usr/bin/firefox -new-window " + url); Robot r = new Robot(); File f = new File("/home/leonardo/Scrivania/skyscann/AutoSave_4.htm"); while (!f.exists()) { // System.out.println("il file non c'e'"); } r.keyPress(KeyEvent.VK_ALT); r.keyPress(KeyEvent.VK_F4); r.keyRelease(KeyEvent.VK_ALT); r.keyRelease(KeyEvent.VK_F4); } catch (Exception e) { System.out.println(e); } }
/** 按Esc键的封装方法 */ public static void pressEscKey() { Robot robot = null; try { robot = new Robot(); } catch (AWTException e) { // TODO Auto-generated catch block e.printStackTrace(); } robot.keyPress(KeyEvent.VK_ESCAPE); robot.keyRelease(KeyEvent.VK_ESCAPE); }
/** * Process the command from client * * @param command the command code */ private void processCommand(int command) { try { Robot robot = new Robot(); switch (command) { case KEY_RIGHT: robot.keyPress(KeyEvent.VK_RIGHT); System.out.println("Right"); // release the key after it is pressed. Otherwise the event just keeps getting trigged robot.keyRelease(KeyEvent.VK_RIGHT); break; case KEY_LEFT: robot.keyPress(KeyEvent.VK_LEFT); System.out.println("Left"); // release the key after it is pressed. Otherwise the event just keeps getting trigged robot.keyRelease(KeyEvent.VK_LEFT); break; } } catch (Exception e) { e.printStackTrace(); } }
public static boolean isSupport() { try { Robot robot = new Robot(); // robot.mouseMove(0, 0); robot.keyPress(KeyEvent.VK_SHIFT); robot.keyRelease(KeyEvent.VK_SHIFT); } catch (Exception e) { e.printStackTrace(); return false; } return true; }
/** * Press a specific key using its char representation. * * @param key char representation of the key */ public void keyPress(char key) { /* check for CTRL+X where X is [A-Z] * CTRL+A = 1, A = 65 */ if (key >= 1 && key <= 0x1A) { key = (char) (key + 64); robot.keyPress(key); return; } nativeKeyboard.keyPress(key); }
private static void GetProxy() throws InterruptedException, AWTException, UnsupportedFlavorException, IOException { Robot robot = new Robot(); Thread.sleep(5000); for (int i = 1; i <= 50; ++i) { robot.keyPress(KeyEvent.VK_CONTROL); robot.keyPress(KeyEvent.VK_A); robot.keyRelease(KeyEvent.VK_CONTROL); robot.keyRelease(KeyEvent.VK_A); Thread.sleep(1000); robot.keyPress(KeyEvent.VK_CONTROL); robot.keyPress(KeyEvent.VK_C); robot.keyRelease(KeyEvent.VK_CONTROL); robot.keyRelease(KeyEvent.VK_C); Thread.sleep(500); Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard(); Transferable t = cb.getContents(null); String readText = (String) t.getTransferData(DataFlavor.stringFlavor); // System.out.println(readText); String filePath = "F:\\Proxys\\"; String fileName = "proxy" + Integer.toString(i) + ".txt"; writeFile(filePath, fileName, readText); robot.keyPress(KeyEvent.VK_CONTROL); robot.keyPress(KeyEvent.VK_TAB); robot.keyRelease(KeyEvent.VK_CONTROL); robot.keyRelease(KeyEvent.VK_TAB); Thread.sleep(1000); } }
// test BUTTON1, 2 and 3 with ALT key public static void testButtonsWithAlt() { System.out.println("Testing buttons with ALT modifier."); f.addMouseListener(adapterTest4); for (int button : mouseButtons) { robot.keyPress(KeyEvent.VK_ALT); robot.mousePress(button); robot.delay(100); robot.mouseRelease(button); robot.keyRelease(KeyEvent.VK_ALT); } robot.delay(1000); f.removeMouseListener(adapterTest4); }
/** * 登录 * * @param driver * @throws Exception * @creatTime 上午9:20:59 * @author XuYi */ protected void login(WebDriver driver) throws Exception { driver.get(SeleniumUtil.BASEURL + "/itoss/webloader"); Thread.sleep(5 * 1000); driver.findElement(By.xpath("//div[3]/div[2]")).click(); driver.findElement(By.xpath("(//input[@type='text'])[2]")).clear(); driver.findElement(By.xpath("(//input[@type='text'])[2]")).sendKeys("admin"); driver.findElement(By.cssSelector("input[type=\"password\"]")).clear(); driver.findElement(By.cssSelector("input[type=\"password\"]")).sendKeys("manage"); Robot r = new Robot(); r.keyPress(KeyEvent.VK_ENTER); r.keyRelease(KeyEvent.VK_ENTER); Thread.sleep(10 * 1000); }
public static void autoA() { spaceBar(); robot.delay(750); robot.mouseMove(605, 250); robot.delay(1000); robot.keyPress(KeyEvent.VK_A); robot.delay(100); robot.keyRelease(KeyEvent.VK_A); if (Math.random() * 10 > 8) // si random, usa la habilidad Q x-D Q(); getHP(); // si le queda poca vida flashea random x-DD System.out.println(listaColoresHP.get(2).getGreen()); if (listaColoresHP.get(2).getGreen() < 50) flashea(); }
public boolean getToolbarViewState(String toolbarName) throws Exception { Boolean state = true; JFrameOperator app = new JFrameOperator("JSystem"); JMenuItemOperator menuItem = chooseMenuItem(app, false, "View", "Toolbars", toolbarName); Component checkBox = menuItem.getSource(); if (checkBox instanceof JCheckBoxMenuItem) { state = ((JCheckBoxMenuItem) checkBox).isSelected(); } else { throw new Exception(toolbarName + "Toolbar menu item is not a checkbox"); } Robot r = new Robot(); r.keyPress(KeyEvent.VK_ESCAPE); r.keyPress(KeyEvent.VK_ESCAPE); return state; }
public void replayKeyTyped(GaudiEvent e, Component c) { /* AWTEvent newe = new KeyEvent(c, KeyEvent.KEY_PRESSED, e.when, e.modifiers, e.keycode,KeyEvent.getKeyText(e.keycode).charAt(0)); System.err.println("[GUIMIN]["+currentEventId+"]-->key typed event at " + e.widgetid+" ;; "+KeyEvent.getKeyText(e.keycode)); try { EventDispatcher ed = new EventDispatcher(c, newe); ed.start(); Thread.sleep(500); if(ed.isAlive()) ed.interrupt(); } catch (InterruptedException e1) { System.err.println("interrompida"); } newe = new KeyEvent(c, KeyEvent.KEY_PRESSED, e.when, e.modifiers, e.keycode,KeyEvent.getKeyText(e.keycode).charAt(0)); System.err.println("[GUIMIN]["+currentEventId+"]-->key typed event at " + e.widgetid+" ;; "+KeyEvent.getKeyText(e.keycode)); try { EventDispatcher ed = new EventDispatcher(c, newe); ed.start(); Thread.sleep(500); if(ed.isAlive()) ed.interrupt(); } catch (InterruptedException e1) { System.err.println("interrompida"); }*/ Robot r; try { r = new Robot(); r.keyPress(e.keycode); // r.delay(10); r.keyRelease(e.keycode); } catch (Throwable e1) { // TODO Auto-generated catch block e1.printStackTrace(); } }
// ISDABENCHMARKsingleReportTest public static void ISDABENCHMARKsingleReportTest() throws InterruptedException, AWTException { WebDriver driver = StaticClass.driver; loginapp(driver); driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS); driver.findElement(By.tagName("body")).sendKeys("keys.down"); driver.findElement(By.tagName("html")).sendKeys(Keys.chord(Keys.CONTROL, Keys.SUBTRACT)); driver.findElement(By.tagName("html")).sendKeys(Keys.chord(Keys.CONTROL, Keys.SUBTRACT)); driver.findElement(By.tagName("html")).sendKeys(Keys.chord(Keys.CONTROL, Keys.SUBTRACT)); driver.findElement(By.xpath(".//*[@id='sidebar']/ul/li[3]/a/span")).click(); driver.findElement(By.xpath(".//*[@id='sidebar']/ul/li[3]/ul/li[1]/a")).click(); driver.findElement(By.xpath(".//*[@id='sidebar']/ul/li[3]/ul/li[1]/ul/li[2]/a")).click(); Thread.sleep(5000); new Select(driver.findElement(By.xpath(".//*[@id='ContentPlaceHolder1_ddlClient']"))) .selectByVisibleText("Delta Advisors LLC"); Thread.sleep(3000); new Select(driver.findElement(By.xpath(".//*[@id='ContentPlaceHolder1_ddlClientEntityList']"))) .selectByVisibleText("Delta Distressed Arbitrage Fund"); Thread.sleep(3000); String parentwindow = driver.getWindowHandle(); // For Parent window driver.findElement(By.xpath(".//*[@id='ContentPlaceHolder1_btnPreview']")).click(); Thread.sleep(10000); for (String Child_Window : driver.getWindowHandles()) { driver.switchTo().window(Child_Window); } Thread.sleep(2000); driver.findElement(By.linkText("Generate PDF")).click(); // Switch to Child window Thread.sleep(3000); driver.findElement(By.xpath(".//*[@id='btnGeneratePDF']")).click(); Thread.sleep(5000); Robot rb = new Robot(); rb.keyPress(KeyEvent.VK_ENTER); Thread.sleep(2000); driver.close(); // Close Child window driver.switchTo().window(parentwindow); // Finally Switch to Thread.sleep(2000); }
/** * Press a specific key using its keycode. * * @param keycode the Java keycode, all available keycodes can be found in java.awt.event.KeyEvent * class (VK_A, VK_SPACE, ...) * @see java.awt.event.KeyEvent */ public void keyPress(int keycode) { if (OSUtils.IS_WINDOWS || OSUtils.IS_MAC) { /* do not allow modifiers for Windows (as * they are handled in native code with * VkScanCode) and Mac OS X */ if (keycode == KeyEvent.VK_ALT || keycode == KeyEvent.VK_SHIFT || keycode == KeyEvent.VK_ALT_GRAPH) { return; } } /* AltGr does not seems to work with robot, handle it via our * JNI code */ if (keycode == KeyEvent.VK_ALT_GRAPH) { symbolPress("altgr"); } else { robot.keyPress(keycode); } }
@Override public void onComputeInstruction(ComputeInstruction instruction) { super.onComputeInstruction(instruction); System.out.println("Received Instruction: " + instruction.toString()); if (instruction.getCommand().equals("KEYPRESS")) { String key = instruction.getPayload("keycode"); int keycode = -1; if (key.equals("up")) { keycode = KeyEvent.VK_UP; } else if (key.equals("down")) { keycode = KeyEvent.VK_DOWN; } else if (key.equals("left")) { keycode = KeyEvent.VK_LEFT; } else if (key.equals("right")) { keycode = KeyEvent.VK_RIGHT; } else if (key.equals("a")) { keycode = KeyEvent.VK_D; } else if (key.equals("b")) { keycode = KeyEvent.VK_S; } else if (key.equals("start")) { keycode = KeyEvent.VK_ENTER; } else if (key.equals("select")) { keycode = KeyEvent.VK_SPACE; } System.out.println("Pressing " + keycode); Robot robot = this.getRobot(); // robot.delay(10); robot.keyPress(keycode); robot.delay(20); robot.keyRelease(keycode); } }
@Test public void dayBookRough() throws IOException, InterruptedException, AWTException { initialize(); openBrowser(); driver.get(CONFIG.getProperty("testSiteName")); login_Valid(); Set<String> handles = driver.getWindowHandles(); System.out.println(handles.size()); Iterator<String> iterate = handles.iterator(); Thread.sleep(5000); String dayBookNumber = getObjectValue("dayBookBullsEyeStatsX"); Thread.sleep(4000); System.out.println(dayBookNumber); getObject("dayBookBullsEyeX").click(); getObjectById("dayBookExportPdfId").click(); handles = driver.getWindowHandles(); iterate = handles.iterator(); String firstWindow = iterate.next(); String SecondWindow = iterate.next(); driver.switchTo().window(SecondWindow); // waitForElementClickableId(15, "dayBookExportPdfDownloadId"); System.out.println(driver.getCurrentUrl()); driver.findElement(By.xpath("//*[@id='download']")).click(); Thread.sleep(4000); Robot rob = new Robot(); rob.keyPress(KeyEvent.VK_ENTER); rob.keyRelease(KeyEvent.VK_ENTER); rob.keyPress(KeyEvent.VK_ENTER); rob.keyRelease(KeyEvent.VK_ENTER); rob.keyPress(KeyEvent.VK_ENTER); rob.keyRelease(KeyEvent.VK_ENTER); rob.keyPress(KeyEvent.VK_ENTER); rob.keyRelease(KeyEvent.VK_ENTER); rob.keyPress(KeyEvent.VK_ENTER); rob.keyRelease(KeyEvent.VK_ENTER); rob.keyPress(KeyEvent.VK_ENTER); rob.keyRelease(KeyEvent.VK_ENTER); // getObjectById("dayBookExportPdfDownloadId").click(); }
@Override public void serialEvent(SerialPortEvent event) { if (event.getEventType() == SerialPortEvent.DATA_AVAILABLE) { List<Byte> readBuffer = new ArrayList<Byte>(); byte b; String keyPress, key, action; int keyCode; try { while ((b = (byte) is.read()) != NEW_LINE) { readBuffer.add(b); } keyPress = new String(getBytes(readBuffer)).trim(); logger.info(keyPress); // if it is a knob turn action we will only get U or D events from the arduino serial // communication if (keyPress.trim().length() == 1) { key = keyPress.trim(); // do a press and release event keyCode = keyMap.get(key); robot.keyPress(keyCode); robot.keyRelease(keyCode); } else { key = keyPress.split(" ")[0]; action = keyPress.split(" ")[1]; keyCode = keyMap.get(key.toLowerCase()); if (lastKeyPressed.equalsIgnoreCase(key)) { // if last key press was the same as now and its a key // release event, we want to hear it if (action.equalsIgnoreCase("released")) { robot.keyRelease(keyCode); lastKeyPressed = key; } else if (System.currentTimeMillis() - lastReadTime > debounceDelay) { // if the last key pressed is the same as the // current one and the debounce delay has elapsed // we want to hear it if (action.equalsIgnoreCase("pressed")) { robot.keyPress(keyCode); } else if (action.equalsIgnoreCase("released")) { robot.keyRelease(keyCode); } lastKeyPressed = key; } } else { // if this key is not the same as the last one // pressed, then we want to hear it :P if (action.equalsIgnoreCase("pressed")) { robot.keyPress(keyCode); } else if (action.equalsIgnoreCase("released")) { robot.keyRelease(keyCode); } lastKeyPressed = key; } } lastReadTime = System.currentTimeMillis(); } catch (Exception e) { logger.error(e.getMessage(), e); } } }