我一直在尝试准确使用下面链接中给出的代码,但无法让它与 IE 11 一起使用。
IE9 自动保存对话框 (vba)
为了方便起见,复制代码:
Option Explicit
Dim ie As InternetExplorer
Dim h As LongPtr
Private Declare PtrSafe Function FindWindowEx Lib "user32" _
Alias "FindWindowExA" (ByVal hWnd1 As LongPtr, _
ByVal hWnd2 As LongPtr, ByVal lpsz1 As String, _
ByVal lpsz2 As String) As LongPtr
Sub Download()
Dim o As IUIAutomation
Dim e As IUIAutomationElement
Set o = New CUIAutomation
h = ie.Hwnd
h = FindWindowEx(h, 0, "Frame Notification Bar", vbNullString)
If h = 0 Then Exit Sub
Set e = o.ElementFromHandle(ByVal h)
Dim iCnd As IUIAutomationCondition
Set iCnd = o.CreatePropertyCondition(UIA_NamePropertyId, "Save")
Dim Button As IUIAutomationElement
Set Button = e.FindFirst(TreeScope_Subtree, iCnd)
Dim InvokePattern As IUIAutomationInvokePattern
Set InvokePattern = Button.GetCurrentPattern(UIA_InvokePatternId)
InvokePattern.Invoke
End Sub
没有找到按钮,意思是执行后
Set Button = e.FindFirst(TreeScope_Subtree, iCnd)
按钮仍然是“无”。 IE11和IE9在这方面有什么不同吗?我应该将“PropertyCondition”更改为其他内容还是我在这里做错了什么?谢谢。
不确定这是否能解决您的问题,但也许您使用的 IE 安装语言与“EN-US”不同。在这种情况下你应该更换
Set iCnd = o.CreatePropertyCondition(UIA_NamePropertyId, "Save")
通过您可以从按钮中逐字获取的属性名称,例如对于“DE-DE”
Set iCnd = o.CreatePropertyCondition(UIA_NamePropertyId, "Speichern")
这对我有帮助。不过我觉得很恶心......
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)