Another application sometimes shows MessageBox with title "Test" and some message inside of MessageBox body, how can i from another application (writed on C++ or C# whatever) get this message and then close it? Code in C#:
[DllImport("user32.dll", SetLastError = true)]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[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;
for (int i = 0; i < 40; i++) // just test cycle
{
IntPtr window = FindWindow(null, "Test");
if (window != IntPtr.Zero) // ok we found it!
{
// code that reads MessageBox message?
.....
// work is done, closing
SendMessage((int)window, WM_SYSCOMMAND, SC_CLOSE, 0);
break;
}
System.Threading.Thread.Sleep(50);
}
Can you help me with this problem? How can i do it?