Ten A先生のブログで、CotEditorで作業中のスクリプトファイルをそのままAdobeアプリで実行できるAppleScriptが紹介されています。
見ていただければ分かりますが、例えばInDesign用について言えば「2021専用」になっています。
僕は仕事の都合でたくさんのバージョンを使い分ける(ただし同時に起動することは稀)ので、InDesignのバージョンの数だけスクリプトファイルが増えてしまうのは面倒くさいなぁと思って少し処理を書き加えました。という記事です。Ten A先生、いつもありがとうございます。
set filePath to "" tell application "CotEditor" if not (exists front document) then display dialog "実行したいファイルを開いておいてね。" buttons {"OK"} default button "OK" with icon stop return end if set filePath to path of document 0 as Unicode text if filePath = "" then display dialog "実行する時はファイルを一度保存しような。" buttons {"OK"} default button "OK" with icon stop return end if if (filePath is not "") then if application "Adobe InDesign 2021" is running then tell application "Adobe InDesign 2021" do script file (filePath as POSIX file) language javascript end tell else if application "Adobe InDesign 2020" is running then tell application "Adobe InDesign 2020" do script file (filePath as POSIX file) language javascript end tell else if application "Adobe InDesign CC 2019" is running then tell application "Adobe InDesign CC 2019" do script file (filePath as POSIX file) language javascript end tell else display dialog "InDesignが起動していません。" buttons {"OK"} default button "OK" with icon stop return end if end if end tell
ご覧の通り、CotEditorからスクリプトを実行するとInDesign 2021→2020→CC2019と順に調べて、見つかったバージョンでそのスクリプトを実行します。どのバージョンも起動されていなければ「起動していません」と警告が出るというものです。
注意点は、このスクリプトファイルを編集する際、利用したいInDesignを全部起動してからにしてください。AppleScriptは保存と同時にコンパイルされるのですが、その際に起動していないInDesignがあると"Adobe InDesign XXX"
のところが全部起動中の別のバージョンに書き換わります。AppleScriptの大嫌いなところですね。
で、これと同じことを職場のマシンでやろうとしたらAppleScriptのコンパイラがうまく通らなくて泣きました。なんなん。
なのでうまくいかなかった…という方はこちらからダウンロードをどうぞ。
最後にショートカットの設定をします。
CotEditorには最初からスクリプトのショートカット設定機能が備わっていますので、それを利用しましょう*1。
というわけで上記共有ファイルは「⌘+R」キーで実行できるようにファイル名を設定しています(ESTKと同じ感覚で使えます)。どうぞお試しください。