close a message box from another program using c#

后端 未结 2 1984
长发绾君心
长发绾君心 2020-12-10 14:41

Here\'s my problem: we have an automated build process for our product. During the compilation of one of the VB6 projects a message box is spit out that requires the user t

相关标签:
2条回答
  • 2020-12-10 15:23

    When you find the message box, try sending it WM_NOTIFY with a BN_CLICKED type and the ID of the OK button.

    0 讨论(0)
  • 2020-12-10 15:37

    You have to found the window, that is the first step. After you can send the SC_CLOSE message using SendMessage.

    Sample

    [DllImport("user32.dll")]
    Public static extern int SendMessage(int hWnd,uint Msg,int wParam,int lParam);
    public const int WM_SYSCOMMAND = 0x0112;
    public const int SC_CLOSE = 0xF060;
    
    IntPtr window = FindWindow(null, "Location Browser Error");
    if (window != IntPtr.Zero)
    {
       Console.WriteLine("Window found, closing...");
    
       SendMessage((int) window, WM_SYSCOMMAND, SC_CLOSE, 0);  
    }
    

    More Information

    • Find and Close the window using WIN API
    0 讨论(0)
提交回复
热议问题