Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I'd like to make a keyboard shortcut that hides all windows on the current desktop, while ignoring windows on other desktops. Is this possible using Applescript?

share|improve this question

1 Answer 1

Here is a suggestion (Works on OSX 10.8)

Using Automator :

  • Create a new Service with automator
  • Select Service receives selected no input in any application
  • Add a Run AppleScript action

Copy this script :

on run {input, parameters}
    tell application "System Events"
        set processList to (every application process whose visible is true)        
        repeat with appProc in processList
            set windowList to every window of appProc
            repeat with aWindow in windowList
                click (third button of aWindow)
            end repeat
        end repeat
    end tell
end run
  • Save your new service
  • In System Preferences > Keyboard > Keyboard Shortcuts > Services add a keyboard shortcut to your news ervice

Edit :

Other script :

on run {input, parameters}
    tell application "Finder"
        set visible of every process whose visible is true and name is not "Finder" to false
        close every window
    end tell
end run

It hides all apps but it closes all finder windows.

share|improve this answer
    
So does this work because only the buttons of windows in the current desktop are clickable? Ideally I'd like the windows to be hidden instead of minimized, ie visible = false. –  conorsleith Jan 19 '13 at 20:06
    
You can't hide a window but you can hide an app. And hiding a app = hiding its windows in every space. –  Matthieu Riegler Jan 19 '13 at 20:09
    
That's fine, I don't have any app windows on multiple desktops. Sorry my terminology is wrong/misleading –  conorsleith Jan 20 '13 at 17:32
    
See my edit, I proposed an other script –  Matthieu Riegler Jan 20 '13 at 19:45
    
I started with something very similar, but it hides all apps on all desktops/spaces instead of just the current one. I'm not sure it's possible to do what I want to do :/ –  conorsleith Jan 20 '13 at 20:42

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.