MSHTML 中的弹出窗口

发布于 2024-11-27 06:22:19 字数 236 浏览 4 评论 0原文

我正在开发一个网络自动化应用程序。

一切都运转良好。现在我遇到了一个问题。

当用户单击链接时,会打开一个新的弹出窗口,其中包含输入字段和按钮,

用户填写字段并按按钮。

我想自动执行此操作,但问题是当我单击链接并显示弹出窗口时,不会触发 Document_Completed 事件。

所以我无法解析这个弹出的 html 并使其自动化。

任何机构有任何有用的建议吗?

I am working on a web automation application.

Every thing is working fine. Now I have stuck into a problem.

When user click over a link a new pop up is opened with input fields and button,

User fill fields and press button.

I want to automate this, but the problem is that when I click link and pop up is displayed no Document_Completed event is fired.

And so I am unable to parse this pop up html and automating it.

Any body has any helpful suggestion?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

喵星人汪星人 2024-12-04 06:22:20

可以通过 WindowFromPoint 函数获取弹出窗口的句柄。然后您可以使用IAccessible接口来访问弹出窗口的元素。像这样的东西:

const uint OBJID_NATIVEOM = 0;
Guid  IID_IAcce = new Guid("{618736e0-3c3d-11cf-810c-00aa00389b71}");

IntPtr inpt = WindowFromPoint( p);

object ptr1 = null;
int l;

l = AccessibleObjectFromWindow(inpt, OBJID_NATIVEOM,    IID_IAcce.ToByteArray(), ref ptr1);
var acc = ptr1 as IAccessible;

One can get handle to popup by WindowFromPoint function. Then you may use IAccessible interface to acsess elements of popup. Something like this:

const uint OBJID_NATIVEOM = 0;
Guid  IID_IAcce = new Guid("{618736e0-3c3d-11cf-810c-00aa00389b71}");

IntPtr inpt = WindowFromPoint( p);

object ptr1 = null;
int l;

l = AccessibleObjectFromWindow(inpt, OBJID_NATIVEOM,    IID_IAcce.ToByteArray(), ref ptr1);
var acc = ptr1 as IAccessible;
木森分化 2024-12-04 06:22:19

这非常棘手。我自己也一直在做类似的事情。您首先需要检查该对话框是 Javascript 还是消息框。使用 javascript 对话框,您可以尝试以下操作:
http://msdn.microsoft.com/en-us/magazine/gg309183.aspx 。据作者称,它还可以与系统对话框一起使用,但对此不太适用。如果你不能做到这一点,你将不得不深入挖掘并尝试通过 Win32Api 进行操作(据我所知)。

系统对话框不是您通常用于此类自动化的 DOM 的一部分。它没有 ID,并且在与操作系统其余部分分开的循环中运行(在非常低的级别上,它故意与所有内容分开)。要进一步了解对话框及其在 Windows 中的工作方式,请查看:http://www.winprog。 org/tutorial/dialogs.html

我没有完整的解决方案,但我正在努力。

This is very tricky. I have been working on something similar myself. You first need to check if the dialog is Javascript or if it is a messagebox. With a javascript dialog you can try this:
http://msdn.microsoft.com/en-us/magazine/gg309183.aspx. It can also work with a system dialog, but is not great for this, according to the author. If you can't make this work, you'll have to dig deep and try manipulating through Win32Api as far as I can tell.

System dialogs are not part of the DOM you would typically use for this type of automation. It has no ID and runs in a separate loop from the rest of the operating system (at a very low level, it is kept seperate from everything on purpose). For further understanding of dialogs and how they work in Windows check this out: http://www.winprog.org/tutorial/dialogs.html

I don't have a full solution to this, but I'm working on it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文