04/10 ドロップされたASをdiff表示 v4
ドロップされたASをFileMergeでビジュアルdiff表示v3のバージョンアップ版です。2つのAppleScriptのファイルをFileMerge(Xcodeをインストールすると一緒に入る)でビジュアルdiff表示します。
GUI Scriptingを用いているため、実行のためにはこれをオンにしておく必要があります。また、本Scriptはアプリケーション形式で保存したうえで実行(AppleScriptのファイルを2つ、ドラッグ&ドロップ)することになります。
| スクリプト名:ドロップされたASをdiff表示 v4 |
| on run –環境確認を行うべき(書いてない) –FileMergeの起動を最初にやっておく if running of application “FileMerge” then –Mac OS X 10.5だか10.6で拡張された属性 –すでに起動している場合には何もしない else tell application “FileMerge” launch end tell end if end run on open fileList tell application “Finder” set sortedList to sort fileList by creation date –オリジナルはmodification dateだったが……趣味の問題? end tell set sortedList to sortedList’s reverse set oldPath to writeASSourceToTempFolder((sortedList’s item 1) as alias) set newPath to writeASSourceToTempFolder((sortedList’s item 2) as alias) do shell script “/usr/bin/opendiff “ & oldPath’s POSIX path’s quoted form & ” “ & newPath’s POSIX path’s quoted form & ” > /dev/null 2>&1 &” –指定プロセスでDialogが出て処理が停まっている場合には、強制的にダイアログをクローズして処理続行させる clickFrontDialog(“FileMerge”) of me end open –AppleScriptのソースを取得してファイルに書き出し on writeASSourceToTempFolder(macPath) set aName to (info for macPath size 0)’s name set tmpPath to ((path to temporary items from system domain) as text) & aName & “__” & (do shell script “/usr/bin/uuidgen”) & “.txt” set scptText to do shell script “/usr/bin/osadecompile “ & macPath’s POSIX path’s quoted form set accessFile to open for access file tmpPath with write permission set eof of accessFile to 0 write scptText to accessFile starting at eof as text close access accessFile return tmpPath end writeASSourceToTempFolder –表示されるダイアログを乗り越えるためのルーチン(「キャンセル」もしくは「Cancel」ではない方のボタンを押す) on clickFrontDialog(aProcName) –余計なプロセスを起動せずにactivate activateAproc(aProcName) of me –ダイアログ検出 tell application “System Events” tell process aProcName if (count every window) ≥ 1 then if subrole of window 1 = “AXDialog” then tell window 1 set bCount to count every button –「キャンセル」もしくは「Cancel」ではない方のボタンを取得 repeat with i in {“キャンセル”, “Cancel”} –キャンセルに該当するキーワードのリストを各国語分だけ用意しておく??? set bList to (every button whose title is not equal to (contents of i)) if length of bList is not equal to bCount then set aButton to first item of bList tell aButton click exit repeat end tell end if end repeat end tell end if end if end tell end tell end clickFrontDialog on activateAproc(aName) tell application “System Events” set aList to every process whose name is aName and visible of it is true if length of aList ≥ 1 then set aProc to first item of aList tell aProc set frontmost to true end tell else tell application aName to activate end if end tell end activateAproc |

































