我正在使用pywinauto来简化我对某些程序的工作。我想在此combobox项目“与参考”中进行选择。我使用app['Setup Potentiodynamic Experiment'].PrintControlIdentifiers()
来获取组合框的名称和类。 Python返回以下内容:
TComboDJ - 'b'vs. Open Circuit'' (L987, T424, R1094, B445)
'b'TComboDJ5''
'b'vs. Open Circuit3''
'b'vs. Open CircuitTComboDJ3''
所以,为了做我想做的事,我用了这个:
app['Setup Potentiodynamic Experiment']["TComboDJ5"].Select("vs. Reference")
出现以下错误:
Exception in Tkinter callback
Traceback (most recent call last):
File "E:\PY\lib\tkinter\__init__.py", line 1550, in __call__
return self.func(*args)
File "E:/Python projects/test/test.py", line 40, in createxp
app['Setup Potentiodynamic Experiment']["TComboDJ5"].Select("vs. Reference")
File "E:\PY\lib\site-packages\pywinauto\application.py", line 245, in __getattr__
return getattr(ctrls[-1], attr)
AttributeError: 'HwndWrapper' object has no attribute 'Select'
据我所知,pywinauto无法将组合框识别为组合框。可以做点什么吗?
答案 0 :(得分:0)
ComboBoxWrapper
可以明确创建:
from pywinauto.controls.win32_controls import ComboBoxWrapper
hwnd_wr = app['Setup Potentiodynamic Experiment']["TComboDJ5"].WrapperObject()
combo = ComboBoxWrapper(hwnd_wr)
combo.Select("vs. Reference")
当然,如果组合框可以响应CB_GETCOUNT
之类的标准窗口消息,它将起作用。并且输出告诉您幸运的是,合并的<title><item_text>
访问名称可用。