[PR]qWr̔e@:邨l̔閧JI



その1 (web関連)その2その3 (iTunes関連)その4 (ルーチンのようなもの、小ネタ)

・エラー処理は適当です。あしからず。

■DVDプレーヤで指定した時間へ飛んで再生するスクリプト
■CotEditorでソートするスクリプト

MacOSX10.3.xでインストールされるAppleScriptには、スクリプトをアプリケーション形式で保存すると日本語が通らないという
重大なバグがあります。アプリケーション形式で保存する場合は、以下の手順で日本語に対応させてください。

  (1) 保存時の「フォーマット」を「アプリケーションバンドル」に。
  (2) Finderで「Japanese.lproj」という名前の空フォルダを作っておく。
  (3) Finderで(1)で保存したアプリを選択し、
    情報を見る=>言語=>追加で、(2)のJapanese.lprojを選ぶ。
  (4) 情報を見る=>言語で、「Japanese」にチェックがついていることを確認。



■DVDプレーヤで指定した時間へ飛んで再生するスクリプト。
標準でついてる「Go To Time...」だと、時間を入力する際に、1時間14分35秒なら「01:14:35」
のように入力しなければならず面倒(「11435」と入力すると「11435秒」と解釈される)。
このスクリプトなら「11435」と入力すれば1時間14分35秒に、「845」と入力すれば8分45秒に
飛べるのでコロンを入力する手間が省けます。

「スクリプト」形式で保存して、「ホーム/ライブラリ/Application Support/DVD Player Scripts」
に入れてください。

tell application "DVD Player" set et to elapsed time set h to round (et / 3600) rounding down set et to et - 3600 * h set m to round (et / 60) rounding down set s to et - 60 * m set t to text returned of (display dialog "Go to time" default answer (h & m & s as string)) if t as number < 10000 then set t to ("0" & t as string) if t as number < 1000 then set t to ("0" & t as string) set {h, m, s} to {(character 1 of t), (character 2 of t & character 3 of t), (character 4 of t & character 5 of t)} if (h as number) > 0 then set h to (3600 * h) if (m as number) > 0 then set m to (60 * m) set elapsed time to h + m + (s as number) end tell


■CotEditorでソートするスクリプト
テキストエディタのCotEditorでソートを行なうスクリプトです。
入力の仕方がちょいとややこしいですが、通常のソートならそのままOKでできます。
tell application "CotEditor" set {the_key, the_rev} to {text returned, button returned} of (display dialog "記入例" & return & "1文字目でソート → 1" & return & "セパレーターが/、その後の3文字目 → 3,/" & return & "セパレーターがタブ、その後の1文字目 → 1,\\t" default answer "1" buttons {"キャンセル", "降順", "昇順"} default button 3) if the_rev is "昇順" then set the_rev to "" if the_rev is "降順" then set the_rev to "-r " set the_sep to "" if the_key contains "," then set the_num to do shell script "echo " & quoted form of the_key & " | sed s/,.*//" set the_sep to do shell script "echo " & quoted form of the_key & " | sed s/" & the_num & "," & "//" end if if the_sep is not "" then set the_key to " -t " & quoted form of the_sep & " -k2." & the_num else set the_key to " -k1." & the_key end if --改行コードがCRの場合LFに変換 set cr_to_lf to "" if line ending of front document is CR then set cr_to_lf to " | tr '" & (ASCII character 13) & "' '" & (ASCII character 10) & "'" set the_contents to text of front document set sorted_contents to do shell script "echo " & quoted form of the_contents & cr_to_lf & " | sort " & the_rev & the_key set text of front document to sorted_contents end tell ちなみに、以下のように改変すればOSX標準のテキストエディットでソートできますが、フォントサイズなどのテキストスタイルが失われてしまいます。
1行目 tell application "CotEditor" → tell application "TextEdit"
下から4行目 if line ending of front document 〜の行を削除



トップページへ戻る

[PR]ŐV̒SI:Ȃł߲ĂȂ̎