org.sikuli.script.Key Java Examples
The following examples show how to use
org.sikuli.script.Key.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Application.java From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 | 6 votes |
/** * Press page down given number of times */ @Action(object = ObjectType.APP, desc = "Perform page down [<Data>] times", input = InputType.YES) public void pageDown() { try { int count = 1; if (Data != null) { count = Integer.valueOf(Data); } for (int i = 1; i <= count; i++) { SCREEN.type(Key.PAGE_DOWN); } Report.updateTestLog(Action, "PageDown [" + Data + "] action is done", Status.DONE); } catch (Exception ex) { Report.updateTestLog(Action, ex.getMessage(), Status.FAIL); Logger.getLogger(Application.class.getName()).log(Level.SEVERE, null, ex); } }
Example #2
Source File: ImageCommand.java From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 | 5 votes |
public void pageDownBrowser(int dh) { if (isHeadless()) { SCREEN.type(Key.PAGE_DOWN); } else { dh = Math.max(0, dh); JavascriptExecutor jse = ((JavascriptExecutor) Driver); jse.executeScript(String.format("window.scrollBy(0, window.innerHeight-%s)", dh)); } }
Example #3
Source File: PreferencesWin.java From SikuliX1 with MIT License | 4 votes |
private void setTxtHotkey(int code, int mod) { cap_hkey = code; cap_mod = mod; _txtHotkey.setText(Key.convertKeyToText(code, mod)); }
Example #4
Source File: KeyboardLayout.java From SikuliX1 with MIT License | 4 votes |
private static Map<Character, int[]> buildWindowsLayout(int keyboarLayoutId) { Map<Character, int[]> layout = new HashMap<>(); layout.putAll(mapKeyCodes(new int[] { WindowsVkCodes.VK_RMENU }, keyboarLayoutId)); layout.putAll(mapKeyCodes(new int[] { WindowsVkCodes.VK_SHIFT }, keyboarLayoutId)); layout.putAll(mapKeyCodes(new int[0], keyboarLayoutId)); // Modifier layout.put(Key.C_SHIFT, new int[] { WindowsVkCodes.VK_SHIFT }); layout.put(Key.C_CTRL, new int[] { WindowsVkCodes.VK_CONTROL }); layout.put(Key.C_ALT, new int[] { WindowsVkCodes.VK_MENU }); layout.put(Key.C_ALTGR, new int[] { WindowsVkCodes.VK_RMENU }); layout.put(Key.C_META, new int[] { WindowsVkCodes.VK_LWIN }); // Cursor movement layout.put(Key.C_UP, new int[] { WindowsVkCodes.VK_UP}); layout.put(Key.C_RIGHT, new int[] { WindowsVkCodes.VK_RIGHT }); layout.put(Key.C_DOWN, new int[] { WindowsVkCodes.VK_DOWN }); layout.put(Key.C_LEFT, new int[] { WindowsVkCodes.VK_LEFT }); layout.put(Key.C_PAGE_UP, new int[] { WindowsVkCodes.VK_PRIOR }); layout.put(Key.C_PAGE_DOWN, new int[] { WindowsVkCodes.VK_NEXT}); layout.put(Key.C_END, new int[] { WindowsVkCodes.VK_END }); layout.put(Key.C_HOME, new int[] { WindowsVkCodes.VK_HOME }); layout.put(Key.C_DELETE, new int[] { WindowsVkCodes.VK_DELETE }); // Function keys layout.put(Key.C_ESC, new int[] { WindowsVkCodes.VK_ESCAPE }); layout.put(Key.C_F1, new int[] { WindowsVkCodes.VK_F1 }); layout.put(Key.C_F2, new int[] { WindowsVkCodes.VK_F2 }); layout.put(Key.C_F3, new int[] { WindowsVkCodes.VK_F3 }); layout.put(Key.C_F4, new int[] { WindowsVkCodes.VK_F4 }); layout.put(Key.C_F5, new int[] { WindowsVkCodes.VK_F5 }); layout.put(Key.C_F6, new int[] { WindowsVkCodes.VK_F6 }); layout.put(Key.C_F7, new int[] { WindowsVkCodes.VK_F7 }); layout.put(Key.C_F8, new int[] { WindowsVkCodes.VK_F8 }); layout.put(Key.C_F9, new int[] { WindowsVkCodes.VK_F9 }); layout.put(Key.C_F10, new int[] { WindowsVkCodes.VK_F10 }); layout.put(Key.C_F11, new int[] { WindowsVkCodes.VK_F11 }); layout.put(Key.C_F12, new int[] { WindowsVkCodes.VK_F12 }); layout.put(Key.C_F13, new int[] { WindowsVkCodes.VK_F13 }); layout.put(Key.C_F14, new int[] { WindowsVkCodes.VK_F14 }); layout.put(Key.C_F15, new int[] { WindowsVkCodes.VK_F15 }); // Toggling keys layout.put(Key.C_SCROLL_LOCK, new int[] { WindowsVkCodes.VK_SCROLL }); layout.put(Key.C_NUM_LOCK, new int[] { WindowsVkCodes.VK_NUMLOCK }); layout.put(Key.C_CAPS_LOCK, new int[] { WindowsVkCodes.VK_CAPITAL }); layout.put(Key.C_INSERT, new int[] { WindowsVkCodes.VK_INSERT }); // Windows special layout.put(Key.C_PAUSE, new int[] { WindowsVkCodes.VK_PAUSE }); layout.put(Key.C_PRINTSCREEN, new int[] { WindowsVkCodes.VK_SNAPSHOT }); // Num pad layout.put(Key.C_NUM0, new int[] { WindowsVkCodes.VK_NUMPAD0 }); layout.put(Key.C_NUM1, new int[] { WindowsVkCodes.VK_NUMPAD1 }); layout.put(Key.C_NUM2, new int[] { WindowsVkCodes.VK_NUMPAD2 }); layout.put(Key.C_NUM3, new int[] { WindowsVkCodes.VK_NUMPAD3 }); layout.put(Key.C_NUM4, new int[] { WindowsVkCodes.VK_NUMPAD4 }); layout.put(Key.C_NUM5, new int[] { WindowsVkCodes.VK_NUMPAD5 }); layout.put(Key.C_NUM6, new int[] { WindowsVkCodes.VK_NUMPAD6 }); layout.put(Key.C_NUM7, new int[] { WindowsVkCodes.VK_NUMPAD7 }); layout.put(Key.C_NUM8, new int[] { WindowsVkCodes.VK_NUMPAD8 }); layout.put(Key.C_NUM9, new int[] { WindowsVkCodes.VK_NUMPAD9 }); // Num pad special layout.put(Key.C_SEPARATOR, new int[] { WindowsVkCodes.VK_SEPARATOR }); layout.put(Key.C_ADD, new int[] { WindowsVkCodes.VK_ADD }); layout.put(Key.C_MINUS, new int[] { WindowsVkCodes.VK_SUBTRACT }); layout.put(Key.C_MULTIPLY, new int[] { WindowsVkCodes.VK_MULTIPLY }); layout.put(Key.C_DIVIDE, new int[] { WindowsVkCodes.VK_DIVIDE }); layout.put(Key.C_DECIMAL, new int[] { WindowsVkCodes.VK_DECIMAL }); layout.put(Key.C_CONTEXT, new int[] { WindowsVkCodes.VK_APPS }); layout.put(Key.C_WIN, new int[] { WindowsVkCodes.VK_LWIN }); // hack: alternative tab in GUI layout.put(Key.C_NEXT, new int[] { -WindowsVkCodes.VK_TAB }); // RETURN, BACKSPACE, TAB layout.put('\r', new int[] { WindowsVkCodes.VK_RETURN }); layout.put('\n', new int[] { WindowsVkCodes.VK_RETURN }); layout.put('\b', new int[] { WindowsVkCodes.VK_BACK }); layout.put('\t', new int[] { WindowsVkCodes.VK_TAB }); // SPACE layout.put(' ', new int[] { WindowsVkCodes.VK_SPACE }); return layout; }
Example #5
Source File: ImageCommand.java From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 | 4 votes |
public String getKeyCode(String data) { switch (data.toUpperCase()) { case "TAB": return Key.TAB; case "ENTER": return Key.ENTER; case "SHIFT": return Key.SHIFT; case "CTRL": return Key.CTRL; case "ALT": return Key.ALT; case "START": return Key.WIN; case "ESC": return Key.ESC; case "DELETE": return Key.DELETE; case "BACKSPACE": return Key.BACKSPACE; case "HOME": return Key.HOME; case "CAPS_LOCK": case "CAPS LOCK": return Key.CAPS_LOCK; case "PAGE_UP": case "PAGEUP": return Key.PAGE_UP; case "PAGE_DOWN": case "PAGEDOWN": return Key.PAGE_DOWN; case "UP": return Key.UP; case "DOWN": return Key.DOWN; case "LEFT": return Key.LEFT; case "RIGHT": return Key.RIGHT; default: return data; } }
Example #6
Source File: HotkeyManager.java From SikuliX1 with MIT License | 2 votes |
/** * install a hotkey listener. * * @param key key character (class Key) * @param modifiers modifiers flag * @param callback HotkeyListener * @return true if success. false otherwise. */ public boolean addHotkey(String key, int modifiers, HotkeyListener callback) { int[] keyCodes = Key.toJavaKeyCode(key.toLowerCase()); int keyCode = keyCodes[0]; return installHotkey(keyCode, modifiers, callback, ""); }
Example #7
Source File: HotkeyManager.java From SikuliX1 with MIT License | 2 votes |
/** * uninstall a hotkey listener. * * @param key key string (class Key) * @param modifiers modifiers flag * @return true if success. false otherwise. */ public boolean removeHotkey(String key, int modifiers) { int[] keyCodes = Key.toJavaKeyCode(key.toLowerCase()); int keyCode = keyCodes[0]; return uninstallHotkey(keyCode, modifiers); }