You will have to use Spy++ or some other tool to get the class name and windows name. They should probably be configurable, don't recommmend hard codeing the values. Here we do a loop and look for the window and then close it. I've included the appropriate imports, windows API signatures and sample code.
//DLL Imports
using System.Runtime.InteropServices;
//For Sending Keys
using System.Windows.Forms;
// Get a handle to an application window.
[DllImport("USER32.DLL", CharSet = CharSet.Unicode)]
private static extern IntPtr FindWindow(string lpClassName,
string lpWindowName);
// Activate an application window.
[DllImport("USER32.DLL")]
private static extern bool SetForegroundWindow(IntPtr hWnd);
Sample Code:
IntPtr handle= IntPtr.Zero;
int retryCount = 0;
//Try until max is reached
while (retryCount < 30)
{
//Get a handle to the window
handle= FindWindow(WindowClassName, WindowName);
//We found the window
if (handle!= IntPtr.Zero)
{
retryCount = 30;
//Send Close Command
SetForegroundWindow(handle);
SendKeys.SendWait("%{F4}");
}
retryCount++;
//Wait 2 seconds before trying again
System.Threading.Thread.Sleep(2000);
}