检测在另一个应用程序中打开的消息框

问题描述:

我正在 VB.NET 中开发 Windows 服务,该服务启动执行某些工作的旧应用程序.该服务充当旧应用的包装器,允许用户自动执行其他手动操作.

I am developing a windows service, in VB.NET, that launches a legacy application that performs some work. The service acts as a wrapper around the legacy app allowing users to automate an otherwise manual operation.

一切都很好,除了旧版应用偶尔会显示一个消息框.执行此操作时,该过程将停止,直到消息框关闭.

Everything is working great, except occasionally the legacy app displays a messagebox. When it does this the process halts until the message box is closed.

由于服务将在服务器上运行,因此没有用户可以关闭消息框.

As the service will be running on a server there will be no user to close the message box.

该服务在 System.Diagnostics.Process 中启动遗留应用程序.

The service launches the legacy application in a System.Diagnostics.Process.

有没有办法检测我使用 System.Diagnostics.Process 启动的进程是否显示了消息框?有没有办法通过代码关闭消息框?

Is there way to detect that a message box has been displayed by a process that I have started using System.Diagnostics.Process? And is there a way to close the messagebox through code?

我还发现 EnumChildWindows 不返回 MessageBox.但是我找到了一个网站,向我展示了如何做到这一点.http://vbcity.com/forums/t/105842.aspx您想通过 GW_ENABLEDPOPUP 调用 GetWindow.它就像一个魅力.感谢 Scott Waletzko!

I also found that EnumChildWindows does not return the MessageBox. But I found a site that showed me how to do it. http://vbcity.com/forums/t/105842.aspx You want to call GetWindow passing in GW_ENABLEDPOPUP. It worked like a charm. Thanks to Scott Waletzko!