How to automate response to msgbox

后端 未结 6 595
遇见更好的自我
遇见更好的自我 2021-01-25 16:08

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

6条回答
  •  臣服心动
    2021-01-25 16:24

    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.

提交回复
热议问题