Applescript: Open with Default Application

202 views
Skip to first unread message

infinitepatt_rns

unread,
Nov 3, 2008, 5:22:44 AM11/3/08
to BBEdit Talk
Hello all,

I'm trying to construct a script that opens a member document of a
project with its default application. The script below (credit to
Michael Tsai) works great for a browser window, but falters with a
project window when modified.


####
tell application "BBEdit"
(* replace disk browser window -> project window in line directly
below)
if class of window 1 is disk browser window then
(* with the replacement above, line directly below returns an error *)
(* the error may be related to use of selection instead of project
item *)
set s to selection of window 1
set f to alias 1 of s
else
set f to file of window 1
end if
end tell

tell application "Finder"
open f
end tell
####


Why find a solution for a bbproj environment? The project windows work
well: immediate access to any type of file (including pdf files with
defaults write preference settings). I just need to bypass the
contextual Reveal in Finder (in the case of xml-type files) and get
the above script working. Thereafter it's easy to bind the script to a
keyboard shortcut, eg, Control-Return.

I am an applescript illiterate. Thanks in advance for any brief
pointers.

johnde...@gmail.com

unread,
Nov 3, 2008, 11:32:06 AM11/3/08
to bbe...@googlegroups.com
At 02:22 -0800 3/11/08, you wrote:

>I'm trying to construct a script that opens a member document of a
>project with its default application. The script below (credit to
>Michael Tsai) works great for a browser window, but falters with a
>project window when modified.

Try this, observing that 'selection' is always a list:


tell application "BBEdit"


if class of window 1 is disk browser window then

set _list to selection in window 1
else
set _list to {file of window 1}


end if
end tell
tell application "Finder"

activate
repeat with _item in _list
open _item
end repeat
end tell

JD

infinitepatt_rns

unread,
Nov 4, 2008, 6:58:47 AM11/4/08
to BBEdit Talk
Thank you for the script JD; works like a charm in disk browser
windows.

Disk browsers seem more flexible and transparent from a scripting
standpoint; less rigid folder and file hierarchy requirements; easier
to
call a selection (_list in the above) rather than calling individual
project items (folders or files).

If I may, BareBones folks, for some future release:

Would it be possible to include some basic bbproj scripts in the pre-
fab
scripts folder? Thanks.
Reply all
Reply to author
Forward
0 new messages