def keypress(self, data): """ Press key. NOTE: keyrelease should be called @param data: data to type. @type data: string @return: 1 on success. @rtype: integer """ window = self._get_front_most_window() key_press_action = KeyPressAction(window, data)
def keypress(self, data): """ Press key. NOTE: keyrelease should be called @param data: data to type. @type data: string @return: 1 on success. @rtype: integer """ key_press_action = KeyPressAction(key_name=data) key_press_action() return 1
def do_keypresses(self): if self.keys and not self.haspressedkeys: self.haspressedkeys = True if has_xkbgroup: with XKeyboard() as xkb: logging.info("xkb %d:%s:%s", xkb.group_num, xkb.group_symbol, xkb.group_name) keys = self.keys.split("]") for key in keys: if (key): key = key[1:] keyparts = key.split(" ") mods = [] for part in keyparts: if part in self.known_keys: mainkey = part elif part in self.known_modifiers: mods.append(part) logging.info("key is %s with modifiers %s" % (mainkey, mods)) keyval = self.known_keys[mainkey] logging.info("%s", keyval) for modifier in mods: modkeypress = KeyPressAction(self.known_modifiers[modifier]) modkeypress._keyPress(self.known_modifiers[modifier]) mainkeypress = KeyPressAction(keyval) mainkeyrelease = KeyReleaseAction(keyval) mainkeypress._keyPress(keyval) mainkeyrelease._keyRelease(keyval) for modifier in mods: modkeypress = KeyReleaseAction(self.known_modifiers[modifier]) modkeypress._keyRelease(self.known_modifiers[modifier]) time.sleep(0.05) t = Timer(1.0, self.do_destroy) t.start()
def multiremove(self, window_name, object_name, row_text_list, partial_match=False): """ Remove multiple row @param window_name: Window name to type in, either full name, LDTP's name convention, or a Unix glob. @type window_name: string @param object_name: Object name to type in, either full name, LDTP's name convention, or a Unix glob. @type object_name: string @param row_text_list: Row list with matching text to select @type row_text: string @return: 1 on success. @rtype: integer """ if partial_match: return self.selectrowpartialmatch(window_name, object_name, row_text) obj = self._get_object(window_name, object_name) self._grab_focus(obj) try: tablei = obj.queryTable() except NotImplementedError: raise LdtpServerException('Object not table type.') key_press_action=KeyPressAction(key_name="<ctrl>") key_press_action() try: for row_text in row_text_list: unselected_rows = False for i in range(0, tablei.nRows): for j in range(0, tablei.nColumns): cell = tablei.getAccessibleAt(i, j) if not cell: continue if cell.childCount > 0: flag = False try: if self._handle_table_cell: # Was externally set, let us not # touch this value flag = True else: self._handle_table_cell = True children = self._list_objects(cell) for child in children: if self._match_name_to_acc(row_text, child): time.sleep(1) size = self._get_size(cell) if pyatspi.state.STATE_SELECTED \ in cell.getState().getStates(): self._mouse_event(size[0] + size[2]/2, size[1] + size[3]/2) else: # Table Cell wasn't selected pass unselected_rows = True break finally: if not flag: self._handle_table_cell = False elif self._match_name_to_acc(row_text, cell): time.sleep(1) size = self._get_size(cell) if pyatspi.state.STATE_SELECTED \ in cell.getState().getStates(): self._mouse_event(size[0] + size[2]/2, size[1] + size[3]/2) unselected_rows = True if not unselected_rows: raise LdtpServerException('Unable to unselect row: %s' % row_text) finally: key_release_action=KeyReleaseAction(key_name="<ctrl>") key_release_action() if unselected_rows: return 1 raise LdtpServerException('Unable to unselect rows')