【发布时间】:2018-06-25 07:41:03
【问题描述】:
我正在尝试根据特定参数在 Power BI 中自动刷新数据。为了调整 Power BI 刷新脚本 (https://github.com/dubravcik/pbixrefresher-python),基于 PyWinAuto。 要调整参数,我必须打开并使用 Power BI 功能区中的下拉菜单,我怀疑在打开下拉菜单时,焦点仍在 PowerBI 的主屏幕上,因此我无法在下拉菜单中进行操作。
如何使用 PyWinAuto 识别并关注下拉菜单?
(另见https://i.imgur.com/pbFmMJa.png)
# Focus on the Power BI window
app = Application(backend = 'uia').connect(path = PBIDesktop.exe)
win = app.window(title_re = '.*Power BI Desktop')
win.wait("enabled", timeout = 300)
win.set_focus()
win.wait("enabled", timeout = 300)
# Open the dropdown menu with Alt+H, then Q
win.type_keys('%HQ')
# Next part doesn't work, I suspect because of no focus on the dropdown menu
win.type_keys('{DOWN}{DOWN}{ENTER}')
【问题讨论】:
-
我看到的是功能区工具栏。它应该类似于 repo 文件夹“examples”中的 MS Paint 示例。
标签: python focus powerbi pywinauto powerbi-desktop