Whenever I download a .dmg file and then open it (usually from the download bar in Chrome), it opens up in the background. Is there any way to get it to open up in front of my window?


To clarify: I want the DMG window to pop up as the active window.

  • When you say open it up, where are you opening it from? Your browser? Finder? Feb 2, 2011 at 18:30
  • 1
    I am pretty sure he means it "pops up" behind your active windows. He wants it to pop up in front of his active windows. Feb 3, 2011 at 3:01
  • That's exactly what I mean Ryan.
    – Epaga
    Feb 3, 2011 at 8:32
  • Often I'm opening it from the browser, but I think even from the Finder it opens behind the active window...
    – Epaga
    Feb 3, 2011 at 8:33
  • Have you managed to get my solution to work, yet? If not I could go into more detail to help you...
    – Asmus
    Feb 12, 2011 at 23:51

3 Answers 3


I created a Folder Action script in Applescript, that might do just what you want. Copy and paste it into a new Applescript, and save it as an Application (without a starting dialogue!) into "/Library/Scripts/Folder Action Scripts/". You can then attach it to any folder (most likely your ~/Downloads/ folder ) by right clicking on the folder and selecting "configure folder actions" from the services drop-out menu. Activate Folder Actions and let the script watch the folder.

What the script basically does, is react on items dropped into the folder it´s attached to and if the dropped item is of Kind:"Image" it attaches the Image as a Volume via the "hdiutil" command line tool.

You can configure it´s behaviour by setting the openWindow and makeFrontmost properties in the Script; this can also be done by double-clicking on the Script after you have saved it as an application - it will then ask in two dialogues on what it´s standard behaviour should be.

I hope this helps,


 property openWindow : true
 property makeFrontmost : true

 on run

    display dialog "Do you want to bring the Finder to the front after new items are added?" buttons {"Don't Activate", "Activate"} default button 2
    if the button returned of the result is "Don't Activate" then
        set makeFrontmost to false
        set makeFrontmost to true
    end if

    display dialog "Open Folder after adding new files?" buttons {"Don't Open", "Open"} default button 2
    if the button returned of the result is "Don't Open" then
        set openWindow to false
        set openWindow to true
    end if

 end run

 on adding folder items to thisFolder after receiving addedItems

    repeat with i from 1 to number of items in addedItems
        set itemKind to the kind of (info for item i of addedItems) as string

        if itemKind is "Disk Image" then
            set itemPath to (quoted form of POSIX path of item i of addedItems)
            end try
        end if

    end repeat

 end adding folder items to

 on showImage(itemPath)

    set volumeMountpointInfo to do shell script "/usr/bin/hdiutil  attach " & itemPath & " | grep Volumes"

    if (openWindow is true) then
        if (makeFrontmost is true) then
            tell application "Finder" to activate
        end if

       set currentDelim to text item delimiters
       set text item delimiters to tab

       set volumeMountpoint to POSIX file (text item 3 of volumeMountpointInfo)

       set text item delimiters to currentDelim

       tell application "Finder" to open folder volumeMountpoint

    end if

 end showImage


second Applescript to determine the kind of file dropped into a folder

On adding folder items to thisFolder after receiving addedItems
repeat with i from 1 to number of items in addedItems
    set itemKind to the kind of (info for item i of addedItems) as string
    display dialog itemKind
end repeat
end adding folder items to

Edited Needs to be "Disk Image" rather than "Image"

  • wow - very cool. unfortunately when I double click it says "You can't open the application because the Classic environment is no longer supported." Say what??
    – Epaga
    Feb 9, 2011 at 19:57
  • I tried a chmod a+x on it but it still gives me that error message.
    – Epaga
    Feb 9, 2011 at 19:59
  • No need to chmod this script! Let me give you a little bit more detail: from /Applications/Utilites/ open the applescript-editor and paste the code I posted above into a new window. In the "Save…" dialogue, select "Application" as file format and make sure that none of the "Options" checkboxes are checked. Once it is saved into /Library/Scripts/Folder Action Scripts/ , it should show up in the "Folder Actions Setup" menu. Can you reach that point?
    – Asmus
    Feb 9, 2011 at 22:36
  • Thanks for the step-by-step. I can get that far and enable that script for the download folder. I double click the script and can set it to open up the finder. Unfortunately it doesn't seem to have any effect at all...neither when downloading a dmg file off the net, nor even when i drag a dmg file into the folder does anything seem to happen. weird, eh?
    – Epaga
    Feb 14, 2011 at 13:02
  • Could you maybe save the second applescript I´ve now posted above as a new folder action and (similar to the one above) attach it to a new folder?
    – Asmus
    Feb 14, 2011 at 16:24

From what I can tell, OS X will only automatically display the contents of a disk image if it is read-only. This is indicated by a pencil with a slash through it in the bottom left of the Finder window when viewing the image's contents.

If you want to change a disk image so that it will do this, you can make an existing disk image read-only by using Disk Utility. Unfortunately, this won't change the behavior for incorrectly-produced images you may download from the Internet.

  1. Mount the disk image you want to auto-open.
  2. Open Disk Utility by searching for it with Spotlight.
  3. Select the "New Image" icon in the toolbar.
  4. Name the file and select "read-only" under "Image Format." New Image dialog
  5. Click "Save." When you mount this new image, it will automatically pop open a Finder window.
  • interesting, thanks! but as you say yourself it doesn't really help me with my actual problem which are DMGs downloaded off the Internet... if I do all this it'd be far easier to open the DMG and then Cmd-Tab it to the front...
    – Epaga
    Feb 4, 2011 at 5:07

This probably does not answer the question sufficiently either, but...

If you press command and click on the item in the download bar, it shows the item in the finder. At that point, simply pressing command-O (or double-clicking the dmg file) will mount it and open it in a new window in the foreground.

  • 2
    The OP is well aware of how to open dmg files. He (and many others) are looking for some way to override the Finder's behavior of "popping under" the window that displays the dmg contents. Feb 14, 2011 at 20:31
  • Yep, vivek is right none of these actually nail the problem. What op is asking for is the default behavior with Safari. I believe this is specifically a chrome issue.
    – user5583
    Apr 13, 2011 at 17:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .