I'm not sure I understand exactly what you want, but maybe the below macro will give you some ideas. It provides a method to detect when a new window has appeared.
It simply pauses until either (the window count has increased) OR (the window title has changed).
###Macro Library [WINDOW] TEST - Pause Until New Window
[WINDOW] TEST - Pause Until New Window.kmmacros (20 KB)