fixed script if no window is active