Notice When Window Being Created of Other Thread or Process

Is there a way to get a notice when there is a window which has just been load and going to be created (e.g. after clicking a button) within other thread or process? I want to use it in Automation for some UI rather than using Start-Sleep for specific seconds/minutes and even not sure that if the loading is fail!

I tried SetWinEventsHook and SetWindowsHookEx API but boh does not work and seems only can run in a Form Class.

I also tried receiving WMI message and succeed to get notice when the process is fully run but not "window being created’.

FindWindow and EnumWindows are also not working because those API can only find the window when it is client-ready but not "window being created’.

Any advise?

This is very vague. There is form class and windows, so is this a .NET Form being generated from Powershell? You are opening child windows with a button click and want to see if something is being completed in the child window? This question seems like a .NET question rather than a Powershell question. Have you tried to search for .NET forums on monitoring child windows?