I wrote a TextMate command to close all HTML output windows: Close All HTML Output Windows.tmCommand. This is very useful, at least to me, when developing some TextMate commands – one can end up with tons of such windows.
The command is a shell script that wraps this piece of AppleScript:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
It was a bit tricky to actually close the window. To use the GUI scripting (to detect
AxWebAreas), one apparently has to talk to the app as a System Events process – which seems to disallow anything like
close theWindow. So I loop over the windows by index, doing GUI scripting by window index in process land and closing windows by index in
tell application land. I loop backwards since closing a window shifts higher indices down.
As a comment in the code mentions, there is an occasional off-by-one bug in the “Closed 123 HTML output windows” tooltip message. Not a big deal, really. Another issue is that any HTML output window that has not completed will prompt on whether to stop its task, and the tooltip will appear even though there might still be windows-with-prompts around.