I’m working on a application that allows you quick access to your network volumes by providing a menubar icon with a drop down menu. You can either choose to connect all the volumes in your preferences, or choose individual volumes from a sub-menu.
When you select an individual volume, a couple of my testers have said it would be nice if the volume opened in Finder after being connected. Althought I have been able to do this with the following code…
tell application "Finder"
open disk "Disk Name"
end tell
…the window opens but isn’t brought to the front and made active, unless Finder was already the active application when the menubar icon was triggered.
If I use this code instead…
tell application "Finder"
activate
open disk "Disk Name"
end tell
…then every single Finder window you have open, as well as this new network volume, is brought above the existing windows on the screen - exactly the same behaviour as if I had just clicked the Finder icon in the Dock.
I want to be able to create a Finder window pointing at this network volume, and bring it to the top/front, without the arrangement of other windows being effected.
I don’t really have an answer, but isn’t this the sort of schizophrenic behaviour the OS X Finder has always exhibited? Sometimes you can bring just one window to the front of others, or going to the Finder via command-Tab brings all forwards. In OS 9 days, clicking the desktop always took you to all Finder windows.
-- John Maisey -- 18 Sept 2007
tell application "Finder"
if (count of Finder windows) is not 0 then
-- If there is an open window.
set myURL to (URL of target of front window)
else if ((count of (get selection)) is not 0) then
-- Or a folder selected.
set myURL to (URL of item 1 of (get selection))
-- If not a folder or disk then set as default.
if item -1 of myURL is not "/" then set myURL to "file://localhost/"
else
-- Otherwise set a default value.
set myURL to "file://localhost/"
end if
end tell
-- Open the URL
open location myURL
It checks to see if there is an open Finder window and shows the front one. If there is no Finder window it opens the first selected disk or folder. Otherwise it opens the window of your local disk.
Using ‘open location’ on the URL of a folder or disk should have the effect you want.
Is it possible to use relative linking here? ie. “…/Folder/Folder/” to open a folder relative to the script file?
I’m looking for a way to create an HTML which will be used for navigating a CD which has numerous folders of Installers. The page would of course have a list of each installer with name and description and a link which ( and here’s what i can’t figure out) reveal the file in the finder. I can’t find an html, javascript, or applescript that will call the finder to open a folder relative to the root of the CD.