1.解决方案如下,引入uiautomation的依赖
2.复制如下函数,直接调用即可
其中uiauto即uiautomation的别称
def downLoad():
saveWindows = uiauto.WindowControl(searchDepth=2, Name='另存为')
saveWindows.SetTopmost(True)
parent = saveWindows.PaneControl(searchDepth=1,
ClassName='DUIViewWndClassName').PaneControl(searchDepth=1,
Name='浏览器窗格').PaneControl(
searchDepth=1, Name='文件夹布局窗格').PaneControl(searchDepth=1, Name='详细信息窗格')
combox = parent.ComboBoxControl(searchDepth=1)
fileNamEdilt = combox.EditControl()
fileName = fileNamEdilt.GetValuePattern().Value +
datetime.datetime.now().strftime('%Y%m%d%H%M%S')
fileNamEdilt.SendKeys(fileName)
saveWindows.ButtonControl(searchDepth=2, Name='保存(S)').Click()