框架通知栏保存按钮

框架通知栏保存按钮

本文介绍了IE11 框架通知栏保存按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在带有 MS Excel 2010 和 IE11 的 64 位系统上,我使用此代码从网站自动下载过程:

On a 64-bit system with MS Excel 2010 and IE11 I'm using this code to automate download process from a website:

hWnd = FindWindowEx(IE.hWnd, 0, "Frame Notification Bar", vbNullString)

If hWnd Then
    hWnd = FindWindowEx(hWnd, 0&, "Button", "Save")
End If

If hWnd Then
    SetForegroundWindow (hWnd)
    Sleep 600
    SendMessage hWnd, BM_CLICK, 0, 0
End If

一切正常,直到框架通知栏出现.我正在获取此窗口的 HWND,但无法获取保存"按钮的 HWND,以便我可以向其发送点击.

Everything goes OK until the Frame Notification Bar appears. I'm getting the HWND of this window, but can't get the HWND of the "Save" button, so that I can send click to it.

推荐答案

如果有人仍在努力寻找解决方案,IE11 就在这里.

If somebody is still trying to find the solution, for IE11 it's here.

在上面Vahagn Sargsyan的代码的第一行,而不是"Frame NotificationBar" 获取对话框的确切标题,可能是英文查看下载 - Internet Explorer".这使您可以获取正确的 hWnd.

On the very first line of the code of Vahagn Sargsyan above, instead of "Frame Notification Bar" get the exact title of the dialog box, which might be in English "View Downloads - Internet Explorer". This allows you to grab the right hWnd.

因为在 IE11 中没有更多按钮加速器来保存文件,请按照 此处 发布的解决方案由 pmr.

Because in IE11 there no more button accelerator to Save files, follow the solution posted here by pmr.

从 pmr 代码中,只需得到以下几行:

From pmr code, just get the following lines:

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

这应该可以解决您的问题.这为我解决了法语本地化问题.

This should solve your issue. This unlocked the situation for me with French localisation.

这篇关于IE11 框架通知栏保存按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 14:08