/** * left click at the given target location<br> Pattern or Filename - do a find before and use the match<br> Region - * position at center<br> Match - position at match's targetOffset<br> * Location - position at that point<br> * * @param <PFRML> to search: Pattern, Filename, Text, Region, Match or Location * @param target Pattern, Filename, Text, Region, Match or Location * @return 1 if possible, 0 otherwise * @throws FindFailed for Pattern or Filename */ public <PFRML> int click(PFRML target) throws FindFailed { return click(target, 0); }
/** * left click at the region's last successful match <br>use center if no lastMatch <br>if region is a match: click * targetOffset * * @return 1 if possible, 0 otherwise */ public int click() { try { // needed to cut throw chain for FindFailed return click(checkMatch(), 0); } catch (FindFailed ex) { return 0; } }
private <PFRML> int keyin(PFRML target, String text, int modifiers) throws FindFailed { if (target != null && 0 == click(target, 0)) { return 0;
aRegion.wait(0.5); win = app.window(); aRegion.click(win); aRegion.write("#M.a#B."); return win; app.focus(); aRegion.wait(0.5); aRegion.click(win); return win; aRegion.wait(0.5); win = app.window(); aRegion.click(win); aRegion.write("#C.a#B."); return win; app.focus(); aRegion.wait(0.5); aRegion.click(win); return win; aRegion.wait(0.5); win = app.window(); aRegion.click(win); app.focus(); aRegion.wait(0.5); aRegion.click(win);
/** * first does a click(target) at the given target position to gain focus/carret <br> and then pastes the text <br> * using the clipboard and strg/ctrl/cmd-v (paste keyboard shortcut) * * @param <PFRML> Pattern, Filename, Text, Region, Match or Location target * @param target Pattern, Filename, Text, Region, Match or Location * @param text a string, which might contain unicode characters * @return 1 if possible, 0 otherwise * @throws FindFailed if not found */ public <PFRML> int paste(PFRML target, String text) throws FindFailed { if (target != null && 0 == click(target, 0)) { return 0; } if (text != null) { App.setClipboard(text); int mod = Key.getHotkeyModifier(); IRobot r = getRobotForRegion(); r.keyDown(mod); r.keyDown(KeyEvent.VK_V); r.keyUp(KeyEvent.VK_V); r.keyUp(mod); return 1; } return 0; } //</editor-fold>