I am developing a C# application to automate the running of a legacy VBScript(vbs) file which calls several VB6 .exe files. The .exe files have message box pop-ups that I need t
Might want to look at using,
SetWinEventHook PInvoke
to detect when dialogs are being created. You can specify the hook to be global or for a specific process. You can set the WINEVENT_OUTOFCONTEXT
flag to ensure that your code isn't actually running in the process you're hooking. And the event you're looking for should be EVENT_SYSTEM_DIALOGSTART
.
Once you've got the hwnd of the dialog (from the event hook), you can use SendMesssage
with WM_COMMAND
or WM_SYSCOMMAND
to get rid of it.