Only one of my two monitors is plugged into my UPS, so when the power goes out I want to be able to immediately move any windows on the blacked-out monitor over to the one that's still on, so I can do whatever hurried housekeeping is necessary before shutting down. I have a macro to do this for all windows of the frontmost application, but I'd like one that will do it for all windows of all running applications at once, rather than me having to manually cycle through active applications.
Here's the macro I have to make the frontmost app's windows visible. (Any window whose left edge is on the left monitor gets moved and slightly tiled. It doesn't need to be pretty, it just needs to work fast.) Is there any way to wrap this in a "for every running application" loop?