PDA

View Full Version : Basic Applescript - How to launch file with default program?




adrian.jfl
Aug 28, 2007, 06:08 AM
Hi,

I want to open a file (say a .txt) with it's default Finder program
association (eg textedit).. I have an application that doesn't support
applescript but will still launch if I double click on it's associated
files.. I'd like to be able to launch them from applescript.

Thanks,
Adrian.



MongoTheGeek
Aug 28, 2007, 12:51 PM
Hi,

I want to open a file (say a .txt) with it's default Finder program
association (eg textedit).. I have an application that doesn't support
applescript but will still launch if I double click on it's associated
files.. I'd like to be able to launch them from applescript.

Thanks,
Adrian.

tell application "Finder" open file "Myfile.txt" of desktop

-or-

do shell script "open ~/desktop/myfile.txt"

-or-

tell application "myNonScriptableApp" to open posix file "/Users/me/desktop/myfile.txt"

All applications even non scriptable ones respond to open, activate, quit, and launch.