Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

A script to close Safari's Downloads window Web Browsers
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.

    •    
  • Currently 3.50 / 5
  You rated: 4 / 5 (6 votes cast)
 
[18,792 views]  

A script to close Safari's Downloads window | 7 comments | Create New Account
Click here to return to the 'A script to close Safari's Downloads window' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
A script to close Safari's Downloads window
Authored by: cclifton on Jul 16, '04 07:02:55PM

That's a clever use of the isDocument property to avoid closing a browser window named "Downloads".

But I don't see how the fact that you "rarely download anything that takes more than 5 minutes" really helps alleviate the risk of closing the Download window in the middle of a download. If your Download window is being closed every 5 minutes---for the sake of discussion, say at 1:00, 1:05, 1:10, etc.---then what is to keep a 2 minute download started at 1:04 from being interupted?

---
Curt



[ Reply to This | # ]
A script to close Safari's Downloads window
Authored by: periche on Jul 16, '04 09:51:57PM

I believe that closing the "Downloads" winddow interrupts any download, in fact will not even clear those already fiinish. You can close and re-open the download windows at any time during a download without affecting the download itself, just the display of the progress is not presented.

Maybe I missundertood? (the problem with closing the window while it is downloading)



[ Reply to This | # ]
A script to close Safari's Downloads window
Authored by: egarc on Jul 17, '04 10:02:37AM

Umm, two things. Closing the download window does not interrupt a download. Second, when the download window comes up, you can type command-W to close it.



[ Reply to This | # ]
A script to close Safari's Downloads window
Authored by: emale on Jul 17, '04 12:20:43PM

I use the Safari plugin "Saft" that closes the download-window after successful downloading.

More Info:
http://haoli.dnsalias.com/Saft/



[ Reply to This | # ]
A script to close Safari's Downloads window
Authored by: aqsalter on Jul 19, '04 08:27:40PM

How about as a 'folder action' script on the downloads folder that basically ran in a loop, checking every 10 secs to see if the downloads had finished? On finished, close the window?

Not an Applescript guru so I can only make the suggestion...



[ Reply to This | # ]
A folder action solution...
Authored by: robg on Jul 26, '04 09:44:16AM

From an anonymous submitter (this was sent as a hint):

I know this should be in the comments, but I think this is big enough to be a hint of its own. The fact that Safari will not auto-close the downloads window is my only regret on leaving Camino!

Basically, I wrapped the script in the following code (from an existing folder action)
on adding folder items to this_folder after receiving these_items
end adding folder items to

I then saved the script in /Library/Script/Folder Action Scripts

I selected Configure Folder Actions from the contextual menu after right-clicking on the desktop.

From the Folder Action Setup app I enabled folder actions, added the Desktop folder (my downloads folder), selected the desktop and added a script (the modified safari download script was listed there) and quit the app.

Now when a download starts, the downloads window opens up and closes within a few seconds. Also, the script is only executed when a download happens (or when something is copied to the desktop, but as there no error (aside from undoing the expose Desktop action) this is really not a problem. This does not interrupt the download process and saves me from closing the darned window manually.

I can always look at the download icon to track progress on large downloads.

Many thanks to pascalpp! Glad to return the favor by pointing to Folder Actions! =)



[ Reply to This | # ]
A script to close Safari's Downloads window
Authored by: donald perreault on Mar 01, '08 11:45:05AM

I have iKeys run the script above every time Safari becomes inactive. This works well because Safari auto opens most downloads and becomes inactive when the download is finished. Not perfect but works most of the time.



[ Reply to This | # ]