【问题标题】:Finding a button in IE11 (IUIAutomationElement)在 IE11 (IUIAutomationElement) 中查找按钮
【发布时间】:2015-12-22 14:15:13
【问题描述】:

我一直在尝试完全使用下面链接中给出的代码,但我无法让它与 IE 11 一起使用。

Automate saveas dialouge for 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”更改为其他内容还是我在这里做错了什么?谢谢。

【问题讨论】:

  • 您在这方面取得了进展吗?我正在尝试使用 Internet Explorer 自动下载 PDF 文件。
  • 遗憾的是没有。我尝试使用不同的条件迭代所有元素,但都是徒劳的。最终我使用了 SendKeys。这不是一个可靠的解决方案,但我不得不接受。

标签: excel vba internet-explorer-11


【解决方案1】:

不确定这是否能解决您的问题,但也许您正在使用不同于“EN-US”的安装语言使用 IE。在这种情况下,您应该更换

Set iCnd = o.CreatePropertyCondition(UIA_NamePropertyId, "Save")

通过您可以从按钮中逐字获取的属性名称,例如对于“DE-DE”

Set iCnd = o.CreatePropertyCondition(UIA_NamePropertyId, "Speichern")

这对我有帮助。但是我觉得很恶心....

【讨论】:

  • 面临同样的问题。而且我只有在提示中才有“保存”。使用 IE 11
  • 解决了同样的问题here
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-04-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多