A script to close Safari's Downloads window

Jul 16, '04 10:07:00AM

Contributed by: pascalpp

Here's a simple script to tell Safari's downloads window to close:

tell application "Safari"
  repeat with w in windows
    if name of w is "Downloads" then
      set isdocument to true
      try
        set d to document of w
        set the result to d
        on error
        set isdocument to false
      end try
         
      if (not isdocument) then
        tell w to close
      end if
    end if
  end repeat
end tell
Like I said, it's simple. :) The on error bit ensures that it's the actual Downloads window, not a browser window viewing a page with the title "Downloads," that's being closed.

If you're running Quickeys or some other automation utility, you can set this script to fire every 5 or 10 minutes. If you don't have Quickeys, you could also fire this script at a given interval using osascript and cron -- see other hints for more on how to do that.

Unfortunately there doesn't seem to be a way to check if anything's currently downloading before closing, but for me that's not a problem as I rarely use Safari to download things that take longer than five minutes.

Comments (7)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20040710172400835