ブラウザのヘルパーアプリv4 for Mac OS X 10.6
http://d.hatena.ne.jp/bootblack/20090208/p1
はSnow LeopardにおいてApple社、モジラ財団、双方からなかったことにされました(苦笑)
Snow Leopard DVD収録のXcode3.2にはアプリケーションの新規プロジェクトのテンプレートとしてはAppleScript Studio Dropletはありませんし、Firefoxでプライベートブラウジング中のダウンロード物はread onlyになっておりFinderラベルがつけられません。
- ピュアAppleScriptだし、NSApplicationの粘着力が欲しかったからstadio用にしたので今度はAutomator用にしてみました。
- read onlyならwrite可にすればいいので、そうしました。通常は read/write可だし、あのエラーだったらそうするという風にしましたが、例によって更に押し進めて!?、ラベルを付けたあとはread only化しています(「--」で一部コメントアウト)。どうするのがいいんでしょうね?
- ファイルの「種類」を見たままの文字列で記述しているので日本語環境専用です(for Japanease OS only)。
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
2010.5.17追記:今、Mac OS X 10.6.3ですけど、どうも最近
- "System Events"の反応がどんくさくなってきた感じ
- Finderの反応がよくなっている感じ
なのでFinderが捕われていない自由な状態の場合は以下のように「種類」の取得を"System Events"経由から"Finder"経由に変えた方が調子いいかもしれません
tell application "System Events" to set theKind to kind of
tell application "Finder" to set theKind to kind of
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-- アプリケーションフォーマットで保存後、以下2行をInfo.plistに追記 -- <key>LSBackgroundOnly</key> -- <true/> on setLabel(anItem) -- try -- tell application "Finder" to set label index of anItem to 7 -- on error errMes number errNum -- if errNum is -5000 then tell application "Finder" set {owner privileges of anItem} to {read write} set label index of anItem to 7 set {owner privileges of anItem} to {read only} end tell -- else -- set logMes to "setLabel Error " & (errNum as string) & ": " & errMes & " '" & (POSIX path of file (anItem as string)) & "'" -- log logMes -- end if -- end try end setLabel on doScan(aItem) tell application "/opt/local/etc/clamav-wrapper.app" to scan aItem end doScan on doExpand(aItem) try tell application "/Applications/StuffIt/StuffIt Expander.app" launch expand aItem as item with continue to expand set expanded_Item to result as alias tell application "System Events" to set theKind to kind of expanded_Item if theKind as string is "ディスクイメージ" then tell application "DiskImageMounter" to open expanded_Item end if return expanded_Item end tell on error errMes number errNum set logMes to "Expand Error " & (errNum as string) & ": " & errMes & " '" & (POSIX path of file (aItem as string)) & "'" log logMes end try end doExpand on LoggingScriptErrorAndQuit(error_message, error_number) log ("AppleScript Error " & (error_number as string) & ": " & error_message) quit end LoggingScriptErrorAndQuit on run {input, parameters} try set tgFile to input as item tell application "System Events" to set theKind to kind of tgFile if ((theKind as string) ends with "archive") or ((theKind as string) ends with "アーカイブ") then set expandedItem to doExpand(tgFile) doScan(expandedItem) setLabel(tgFile) tell application "/Applications/StuffIt/StuffIt Expander.app" to quit else if (theKind as string is "ディスクイメージ") then tell application "DiskImageMounter" to open tgFile doScan(tgFile) setLabel(tgFile) else if (theKind as string) contains "PDF" then tell application "Preview" to open tgFile doScan(tgFile) setLabel(tgFile) tell application "Preview" to activate else doScan(tgFile) setLabel(tgFile) end if on error error_message number error_number LoggingScriptErrorAndQuit(error_message, error_number) end try end run