문제

This is my first time using applescript, I'm trying to open a file from a website in the default application for that file type and am not sure how to do it.

For example:

The file http://test.com/1234.docx should open in OpenOffice if they have that installed.

I can only get it to open in Safari, which I don't want because we use WebDav so the file is editable.

Is there any way to find the default text editor and open a url with that program?

도움이 되었습니까?

해결책

You can use Finder's open command to open a file in the default application:

tell application "Finder"
    open POSIX file "/Library/Desktop Pictures/Abstract.jpg"
end tell

default application of (info for) gets the default application:

tell application "Finder"
    default application of (info for POSIX file "/Library/Desktop Pictures/Abstract.jpg")
end tell

You can use perl to get the default application for a URL scheme:

VERSIONER_PERL_PREFER_32_BIT=1 perl -MMac::InternetConfig -le 'print +(GetICHelper "mailto")[1]'

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top