easy enough method: (not tested code)
method: repeadedly get the id of active window, keep note what it was before and see if it's changed yet
Code:
currentwin := "" ; make a variable to compare against later
SetTimer, CheckMergeActiveWindow, 1000 ; run every second
CheckMergeActiveWindow:
Winget, id, id, A ;get the id of currently active window
Wingetclass, class, ahk_id%id% ; get it's class
if (class == "swt_window0")
{
; it's a merge window
if (id != currentwin)
{
;doesn't match so it's a different window
currentwin := id ; save it's id for next comparison
; do whatever function is wanted here
}
}
return