def _ctrl_identifiers(self): ctrls = _resolve_control(self.criteria) if ctrls[-1].IsDialog(): # dialog controls are all the control on the dialog dialog_controls = ctrls[-1].Children() ctrls_to_print = dialog_controls[:] # filter out hidden controls ctrls_to_print = [ ctrl for ctrl in ctrls_to_print if ctrl.IsVisible() ] else: dialog_controls = ctrls[-1].TopLevelParent().Children() ctrls_to_print = [ctrls[-1]] # build the list of disambiguated list of control names name_control_map = findbestmatch.build_unique_dict(dialog_controls) # swap it around so that we are mapped off the controls control_name_map = {} for name, ctrl in name_control_map.items(): control_name_map.setdefault(ctrl, []).append(name) return control_name_map
def _ctrl_identifiers(self): ctrls = _resolve_control( self.criteria) if ctrls[-1].IsDialog(): # dialog controls are all the control on the dialog dialog_controls = ctrls[-1].Children() ctrls_to_print = dialog_controls[:] # filter out hidden controls ctrls_to_print = [ ctrl for ctrl in ctrls_to_print if ctrl.IsVisible()] else: dialog_controls = ctrls[-1].TopLevelParent().Children() ctrls_to_print = [ctrls[-1]] # build the list of disambiguated list of control names name_control_map = findbestmatch.build_unique_dict(dialog_controls) # swap it around so that we are mapped off the controls control_name_map = {} for name, ctrl in name_control_map.items(): control_name_map.setdefault(ctrl, []).append(name) return control_name_map
def PrintControlIdentifiers(self): """Prints the 'identifiers' If you pass in a control then it just prints the identifiers for that control If you pass in a dialog then it prints the identiferis for all controls in the dialog :Note: The identifiers printed by this method have not been made unique. So if you have 2 edit boxes, they will both have "Edit" listed in their identifiers. In reality though the first one can be refered to as "Edit", "Edit0", "Edit1" and the 2nd should be refered to as "Edit2". """ #name_control_map = self._ctrl_identifiers() ctrls = _resolve_control( self.criteria) if ctrls[-1].IsDialog(): # dialog controls are all the control on the dialog dialog_controls = ctrls[-1].Children() ctrls_to_print = dialog_controls[:] # filter out hidden controls ctrls_to_print = [ ctrl for ctrl in ctrls_to_print if ctrl.IsVisible()] else: dialog_controls = ctrls[-1].TopLevelParent().Children() ctrls_to_print = [ctrls[-1]] # build the list of disambiguated list of control names name_control_map = findbestmatch.build_unique_dict(dialog_controls) # swap it around so that we are mapped off the controls control_name_map = {} for name, ctrl in name_control_map.items(): control_name_map.setdefault(ctrl, []).append(name) print "Control Identifiers:" for ctrl in ctrls_to_print: print "%s - '%s' %s"% ( ctrl.Class(), ctrl.WindowText().encode("unicode-escape"), str(ctrl.Rectangle())) print "\t", names = control_name_map[ctrl] names.sort() for name in names: print "'%s'" % name.encode("unicode_escape"), print
def PrintControlIdentifiers(self): """Prints the 'identifiers' If you pass in a control then it just prints the identifiers for that control If you pass in a dialog then it prints the identiferis for all controls in the dialog :Note: The identifiers printed by this method have not been made unique. So if you have 2 edit boxes, they will both have "Edit" listed in their identifiers. In reality though the first one can be refered to as "Edit", "Edit0", "Edit1" and the 2nd should be refered to as "Edit2". """ #name_control_map = self._ctrl_identifiers() ctrls = _resolve_control( self.criteria) if ctrls[-1].IsDialog(): # dialog controls are all the control on the dialog dialog_controls = ctrls[-1].Children() ctrls_to_print = dialog_controls[:] # filter out hidden controls ctrls_to_print = [ctrl for ctrl in ctrls_to_print if ctrl.IsVisible()] else: dialog_controls = ctrls[-1].TopLevelParent().Children() ctrls_to_print = [ctrls[-1]] # build the list of disambiguated list of control names name_control_map = findbestmatch.build_unique_dict(dialog_controls) # swap it around so that we are mapped off the controls control_name_map = {} for name, ctrl in name_control_map.items(): control_name_map.setdefault(ctrl, []).append(name) print "Control Identifiers:" for ctrl in ctrls_to_print: print "%s - '%s' %s"% ( ctrl.Class(), ctrl.WindowText().encode("unicode-escape"), str(ctrl.Rectangle())) print "\t", names = control_name_map[ctrl] names.sort() for name in names: print "'%s'" % name.encode("unicode_escape"), print