在IE11中找到一个按钮(IUIAutomationElement) [英] Finding a button in IE11 (IUIAutomationElement)
问题描述
我一直在尝试使用下面链接中给出的代码,但我无法使其与IE 11一起使用。
I have been trying to use exactly the code given in the link below but I cannot get it to work with IE 11.
复制代码以方便:
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
按钮没有找到,意思是执行
The button is not found, meaning after executing
Set Button = e.FindFirst(TreeScope_Subtree, iCnd)
按钮仍然是无。 IE11在这方面与IE9有什么不同吗?我应该将PropertyCondition改成别的还是我在这里做错事?谢谢。
Button is still 'nothing'. Is IE11 any different from IE9 in this respect? Should I change "PropertyCondition" to something else or am I doing something wrong here? Thank you.
推荐答案
不知道这是否解决了您的问题,但也许您正在使用不同于EN-我们。在这种情况下,您应该替换
Not sure if this solves your prob but maybe you are using IE in a installation language different from "EN-US". In this case you should replace
Set iCnd = o.CreatePropertyCondition(UIA_NamePropertyId, "Save")
通过属性名称,您可以从按钮逐字逐字地执行,例如对于DE-DE
by the property name which you can take verbatim from the button, e.g. for "DE-DE"
Set iCnd = o.CreatePropertyCondition(UIA_NamePropertyId, "Speichern")
这对我有帮助。但是我觉得很恶心....
That helped for me. However I find it disgusting ....
这篇关于在IE11中找到一个按钮(IUIAutomationElement)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!