这是我的问题:我们的产品有一个自动化构建过程。在编译VB6项目的过程中,会弹出一个消息框,需要用户点击“确定”才能继续。这对于自动化处理来说是个坏事,因为它可能会一直停留在那里,直到有人点击“确定”。我们已经研究了VB6代码,试图抑制消息框,但目前没有人能够解决。因此,作为一个临时解决方案,我正在开发一个程序,在后台运行,当消息框弹出时,关闭它。到目前为止,我能够检测到消息框何时弹出,但我似乎找不到一个正确关闭它的函数。该程序是用C#编写的,我使用user32.dll中的FindWindow函数获取窗口指针。到目前为止,我已经尝试了closeWindow、endDialog和postMessage等方法来关闭它,但都没有成功。closeWindow只是最小化它,endDialog会出现内存异常,而postMessage则无效。有没有人知道其他可以解决这个问题的函数,或者其他消除这个消息的方法?谢谢。
这是我目前拥有的代码:
class Program
{
[DllImport("user32.dll", SetLastError = true)]
private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
static void Main(string[] args)
{
IntPtr window = FindWindow(null, "Location Browser Error");
while(window != IntPtr.Zero)
{
Console.WriteLine("Window found, closing...");
//use some function to close the window
window = IntPtr.Zero;
}
}
}