Yes, exactly. I'm sure there are more elegant answers — plus watching events so that it can hide the window right away instead of running in a loop — but I haven't used the accessibility APIs much lately and this is the first working approach I found.