3_アプリ指定サンプル.scpt
【スクリプトエディタで開く】 |
3_アプリ指定サンプル.scpt.scpt | ソース |
|---|
| 001 | #!/usr/bin/env osascript |
| 002 | #coding: utf-8 |
| 003 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7-- |
| 004 | (* |
| 005 | テスト用のサンプルスクリプト |
| 006 | 複数のファイルを |
| 007 | HTMLファイルをデフォルトのWEBブラウザ |
| 008 | (HTMLと関連づけられているアプリケーション)で開きます |
| 009 |
|
| 010 |
|
| 011 |
|
| 012 | バンドルIDを指定(開くアプリケーションを指定)して開きます |
| 013 | この方法だと発生しない |
| 014 | noteの記事用のデモスクリプト |
| 015 | https://note.com/quicktimer/n/nd0342b80d2f7 |
| 016 |
|
| 017 | com.cocolog-nifty.quicktimer.icefloe *) |
| 018 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7-- |
| 019 | use AppleScript version "2.8" |
| 020 | use scripting additions |
| 021 |
|
| 022 | set listFilePath to {"/Library/Documentation/License.lpdf/Contents/Resources/English.lproj/License.html", "/Library/Documentation/License.lpdf/Contents/Resources/German.lproj/License.html", "/Library/Documentation/License.lpdf/Contents/Resources/French.lproj/License.html", "/Library/Documentation/License.lpdf/Contents/Resources/Dutch.lproj/License.html", "/Library/Documentation/License.lpdf/Contents/Resources/Italian.lproj/License.html", "/Library/Documentation/License.lpdf/Contents/Resources/Japanese.lproj/License.html", "/Library/Documentation/License.lpdf/Contents/Resources/Spanish.lproj/License.html"} as list |
| 023 |
|
| 024 | set listAliasFilePath to {} as list |
| 025 | repeat with itemFilePath in listFilePath |
| 026 | set itemAlisFilePath to (POSIX file itemFilePath) as alias |
| 027 | set end of listAliasFilePath to itemAlisFilePath |
| 028 | end repeat |
| 029 |
|
| 030 |
|
| 031 | repeat with itemAliasFilePath in listAliasFilePath |
| 032 | set aliasFilePath to itemAliasFilePath as alias |
| 033 | |
| 034 | tell file aliasFilePath |
| 035 | set recordInfoFor to (info for) as record |
| 036 | end tell |
| 037 | |
| 038 | set strUTI to (type identifier of recordInfoFor) as text |
| 039 | |
| 040 | if strUTI starts with "dyn." then |
| 041 | tell application "Finder" |
| 042 | open file alisFilePath |
| 043 | end tell |
| 044 | tell application "Finder" to activate |
| 045 | else |
| 046 | set aliaAppPath to (default application of recordInfoFor) as alias |
| 047 | tell file aliaAppPath |
| 048 | set recordInfoFor to (info for) as record |
| 049 | end tell |
| 050 | set strBundleID to (bundle identifier of recordInfoFor) as text |
| 051 | tell application id strBundleID |
| 052 | open location aliasFilePath |
| 053 | end tell |
| 054 | end if |
| 055 | |
| 056 | |
| 057 | end repeat |
| 058 |
|
| 059 |
|
| 060 | return |
| 061 |
|
| AppleScriptで生成しました |
|---|