findbestmatch 用户模块类
用于查找列表中字符串最接近匹配项的模块
exception pywinauto.findbestmatch.MatchError(items=None, tofind='')
找不到合适的匹配项
findbestmatch.UniqueDict
class pywinauto.findbestmatch.UniqueDict
一个字典子类,用于处理使其键唯一
findbestmatch.UniqueDict.find_best_matches
pywinauto.findbestmatch.UniqueDict.find_best_matches(search_text, clean=False, ignore_case=False)
返回项目中search_text的最佳匹配项
参数:
参数 | 说明 |
---|---|
search_text | 要查找的文本 |
clean | 是否清除字符串中的非文本字符 |
ignore_case | 不敏感地比较字符串大小写 |
findbestmatch.build_unique_dict
pywinauto.findbestmatch.build_unique_dict(controls)
生成消除歧义的控件列表
分离出不同的函数,以便我们可以获取用于打印的控制标识符。
findbestmatch.find_best_control_matches
pywinauto.findbestmatch.find_best_control_matches(search_text, controls)
返回与 search_text 匹配的最佳控件
这与 find_best_match 略有不同,因为它使用来自每个控件的信息构建要搜索的文本项列表。因此,例如,对于有一个 OK、Button,则以下内容都添加到搜索列表中:“OK”、“Button”、“OKButton”
但是,如果有一个 ListView(没有可见的“文本”),那么它只会添加“ListView”。
findbestmatch.find_best_match
pywinauto.findbestmatch.find_best_match(search_text, item_texts, items, limit_ratio=0.5)
返回回与 search_text 最匹配的物品
参数 | 说明 |
---|---|
search_text | 要搜索的文本 |
item_texts | 要搜索的文本列表 |
items | 与要搜索的文本列表对应的项目列表(1 到 1) |
limit_ratio | 文本与最佳匹配的匹配程度。如果最佳匹配项匹配值低于此匹配项,则不将其视为匹配项,并引发 MatchError(默认值 = 0.5) |
findbestmatch.get_control_names
pywinauto.findbestmatch.get_control_names(control, allcontrols, textcontrols)
返回此控件的名称列表
findbestmatch.get_non_text_control_name
pywinauto.findbestmatch.get_non_text_control_name(ctrl, controls, text_ctrls)
通过查找其上方和左侧最接近的文本控件来返回此控件的名称
findbestmatch.is_above_or_to_left
pywinauto.findbestmatch.is_above_or_to_left(ref_control, other_ctrl)
如果other_ctrl位于ref_control的上方或左侧,则返回 true