Wait until window is ready before doing anything