Pywinauto - 选择选项卡时出现COMError

时间:2017-08-28 08:19:46

标签: python excel ui-automation pywinauto comtypes

我最近遇到了一个问题,当我在excel文档中选择特定标签(工作表)时,出现以下错误:

c:\python27\lib\site-packages\pywinauto\controls\uia_controls.pyc in select(self, item)
    402     def select(self, item):
    403         """Select a tab by index or by name"""
--> 404         self._select(item)
    405         return self
    406

c:\python27\lib\site-packages\pywinauto\controls\uiawrapper.pyc in _select(self, item)
    604         if item_index < len(list_):
    605             wrp = list_[item_index]
--> 606             wrp.iface_selection_item.Select()
    607         else:
    608             raise IndexError("item not found")

COMError: (-2147467263, 'Not implemented', (None, None, None, 0, None))

这是代码:

app = pywinauto.Application(backend="uia").connect(process=43800)
tab_list = app.top_window().descendants(control_type="Tab")
tab_menu = tab_list[1]
tab_menu.select(1)

excel文档有多张表 选项卡窗口是“ uia_controls.TabControlWrapper - 'Sheet1',TabControl,3527539 ”。

似乎方法: get_selected_tab() tab_count()工作。所以唯一的问题是“ select()”方法应该实际选择标签。

我在多个excel文件和不同环境(python2.7,Windows 10和Windows 2016,有和没有管理员权限)上测试过它。

这可能是什么问题?这个问题有解决方案或解决方法吗?

感谢。

0 个答案:

没有答案
相关问题