/** * Types the given text without checking location or event confirmation. * * @param text The text to type. */ public void rcNativeInputText(String text) { try { KeyTyper.getInstance().nativeTypeString(text); } catch (AWTException e) { throw new RobotException(e); } }
/** * Perform a keystroke specified according <a * href=http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/KeyStroke.html#getKeyStroke(java.lang.String)> * string representation of a keystroke </a>. This method does not wait for event confirmation, as * we have no way of confirming events on OS-native widgets. * * @param modifierSpec the string representation of the modifiers * @param keySpec the string representation of the key */ public void rcNativeKeyStroke(String modifierSpec, String keySpec) { if (keySpec == null || keySpec.trim().length() == 0) { throw new StepExecutionException( "The base key of the key stroke " //$NON-NLS-1$ + "must not be null or empty", //$NON-NLS-1$ EventFactory.createActionError()); } try { KeyTyper typer = KeyTyper.getInstance(); String keyStrokeSpec = keySpec.trim().toUpperCase(); String mod = KeyStrokeUtil.getModifierString(modifierSpec); if (mod.length() > 0) { keyStrokeSpec = mod + " " + keyStrokeSpec; // $NON-NLS-1$ } typer.type(keyStrokeSpec, null, null, null); } catch (AWTException e) { throw new RobotException(e); } }