Tell me more ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have various windows with the same title "MyTitle" across different running applications, which also have other windows with unique titles.

Is there a way I can programatically cause all of these windows to minimize in an equivalent way to clicking the yellow minimize button?

share|improve this question

2 Answers

This can likely be done with applescript. I know that you can minimize a single application with this code.

tell application "Safari"
set miniaturized of window 1 to true
end tell 

You can probably select the windows based on their title, you should be able to use the same "set min..." command though.

share|improve this answer

To go across all applications you will need to enable “GUI scripting” and use System Events.

Open the Universal Access preference pane and make sure “Enable access for assistive devices” is checked.

Then this AppleScript should be close to what you want:

set searchString to "whatever"
tell application "System Events"
    repeat with aWindow in ¬
        (get windows of (application processes whose visible is true) ¬
            whose name contains searchString)
        set aWindow to contents of aWindow
        if aWindow is not missing value and ¬
            (exists attribute "AXMinimized" of aWindow) then ¬
            set value of attribute "AXMinimized" of aWindow to true
    end repeat
end tell
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.