How does AHK monitor the IE save dialog box and wait for the dialog box to appear?

as shown in the following figure, I need to wait for the AHK to monitor the save dialog box in IE before doing anything else.

Mar.05,2021

generally speaking, the first thing to do is to use OnMessage to listen for messages. You may use DLLCALL, to call the system API, but I'm not sure which one to use. I've seen other people use it like this before. Post the code here. This code can monitor a lot of interface changes, which may enlighten your question. The comments in it are not quite right, because I have changed it several times, but the core part is fine.

; -sharp ShellMessage()
Gui +LastFound
hWnd := WinExist()
DllCall( "RegisterShellHookWindow", UInt,hWnd )
MsgNum := DllCall( "RegisterWindowMessage", Str,"SHELLHOOK" )
;"MsgNum","ShellMessage"
OnMessage( MsgNum, "ShellMessage")

; -sharp 
cn_win := ["Win_10_VM - VMware Workstation"]
loop % cn_win.MaxIndex()
GroupAdd,cn,% cn_win[A_Index]

ShellMessage( wParam,lParam ) {

    ;1 
    ;2 
    ;3 SHELL 
    ;4 
    ;5 
    ;6 Windows 
    ;7 
    ;8 
    ;9 
    ;10 
    ;11
    ;12 APPCOMMANDWM_APPCOMMAND
    ;13 wParam=hWnd
    ;14 wParam=hWnd
    ;&H8000& 
    ;53 
    ;54 
    ;32772 
    
    ;
    if ( wParam = 1 )
    {
        Sleep, 1000
            return
    }
    ;
    if ( wParam = 32772 ){
        if WinActive("Win_10_VM"){
        MsgBox,3
        }

return
    }
}


Menu