I want to close the window when the alert window appears

58 Views Asked by At

I am making an automation program, but after the alert message is issued in a certain section, the program does not proceed anymore. After pressing the alert message, the program will resume. Is there any way to recognize the alert message window?

I tried to get the handle of the alert message by getting the process id using spy ++ but it failed The handle I want is the fourth of # 32770's children

using System;
using System.Runtime.InteropServices; 

namespace _1_1Con
{
    class Class1
    {
        [DllImport("user32.dll")] 
        public static extern IntPtr GetWindow(IntPtr hWnd, int uCmd);

        [DllImport("user32.dll")]
        public  static extern int  FindWindow(string  lpClassName,string lpWindowName);

        [DllImport("user32.dll")]
        public  static extern int  FindWindowEx(int  hWnd1,int hWnd2,string  lpsz1,string  lpsz2);

        [DllImport("user32.dll")]
        public  static extern int  SendMessage(int  hwnd,int  wMsg,int wParam,int  lParam);

        const int GW_CHILD = 5;

        [STAThread]
        static void Main(string[] args)
        {

            int hw1=FindWindow(null,"#32770");

            int hwnd_four=GetWindow(hw1,GW_CHILD);


        }
    }
}
0

There are 0 best solutions below