use AppleScript version "2.8"
use framework "Foundation"
use scripting additions
doLogView()
property objMe : a reference to current application
property objNSString : a reference to objMe's NSString
property objNSMutableString : a reference to objMe's NSMutableString
property objNSURL : a reference to objMe's NSURL
property objNSNotFound : a reference to 9.22337203685477E+18 + 5807
set objFileManager to objMe's NSFileManager's defaultManager()
tell application "Finder"
set aliasMe to path to me as alias
log aliasMe as alias
end tell
set strMePath to POSIX path of aliasMe as text
log strMePath as text
set ocidMePathString to objNSString's stringWithString:strMePath
log ocidMePathString as text
log className() of ocidMePathString as text
set ocidMePathNSURL to objNSURL's fileURLWithPath:ocidMePathString
log ocidMePathNSURL as text
log className() of ocidMePathNSURL as text
set ocidMePathContainer to ocidMePathNSURL's URLByDeletingLastPathComponent
log ocidMePathContainer as text
log className() of ocidMePathContainer as text
set ocidImportDataPath to ocidMePathContainer's URLByAppendingPathComponent:"ImportData/Hand.bin"
log ocidImportDataPath as text
log className() of ocidImportDataPath as text
set strImportDataPath to ocidImportDataPath's |path|() as text
set ocidUserLibraryPath to (objFileManager's URLsForDirectory:(objMe's NSLibraryDirectory) inDomains:(objMe's NSUserDomainMask))
log ocidUserLibraryPath as text
log className() of ocidUserLibraryPath as text
set ocidNsurlLibraryPath to ocidUserLibraryPath's objectAtIndex:0
log ocidNsurlLibraryPath as text
log className() of ocidNsurlLibraryPath as text
set ocidPreferencesPath to ocidNsurlLibraryPath's URLByAppendingPathComponent:"Preferences"
log ocidPreferencesPath as text
log className() of ocidPreferencesPath as text
set ocidAcrobatReaderPlistPath to ocidPreferencesPath's URLByAppendingPathComponent:"com.adobe.Reader.plist"
log ocidAcrobatReaderPlistPath as text
log className() of ocidAcrobatReaderPlistPath as text
set ocidAcrobatProPlistPath to ocidPreferencesPath's URLByAppendingPathComponent:"com.adobe.Acrobat.Pro.plist"
log ocidAcrobatProPlistPath as text
log className() of ocidAcrobatProPlistPath as text
set strAcrobatProPlistPath to ocidAcrobatProPlistPath's |path|() as text
set strAcrobatReaderPlistPath to ocidAcrobatReaderPlistPath's |path|() as text
log strAcrobatProPlistPath as text
log strAcrobatReaderPlistPath as text
set boolChkAcrobatProPlistPath to (ocidAcrobatProPlistPath's checkResourceIsReachableAndReturnError:(missing value))
log boolChkAcrobatProPlistPath as boolean
set boolChkAcrobatReaderPlistPath to (ocidAcrobatReaderPlistPath's checkResourceIsReachableAndReturnError:(missing value))
log boolChkAcrobatReaderPlistPath as boolean
if boolChkAcrobatProPlistPath is true then
try
set strCommandText to "/usr/libexec/PlistBuddy -c \"Print :DC:Selection:DefaultSelect:1\" \"" & strAcrobatProPlistPath & "\""
set strCommandResult to (do shell script strCommandText) as text
log strCommandResult
on error
log "設定項目が見つかりません"
set strCommandResult to ""
end try
if strCommandResult contains "Hand" then
set strCommandResult to ""
log "設定済みです"
else
set strCommandResult to ""
try
set strCommandText to "/usr/libexec/PlistBuddy -c \"Delete :DC:Selection:DefaultSelect:1\" \"" & strAcrobatProPlistPath & "\""
do shell script strCommandText
end try
delay 1
set strCommandText to "/usr/libexec/PlistBuddy -c \"Import :DC:Selection:DefaultSelect:1 '" & strImportDataPath & "'\" '" & strAcrobatProPlistPath & "'"
do shell script strCommandText
delay 1
set strCommandText to "/usr/libexec/PlistBuddy -c \"Print :DC:Selection:DefaultSelect:1\" \"" & strAcrobatProPlistPath & "\""
set strCommandResult to (do shell script strCommandText) as text
if strCommandResult contains "Hand" then
log "設定完了"
else
log "設定に失敗しました"
end if
set strCommandResult to ""
end if
end if
if boolChkAcrobatReaderPlistPath is true then
try
set strCommandText to "/usr/libexec/PlistBuddy -c \"Print :DC:Selection:DefaultSelect:1\" \"" & strAcrobatReaderPlistPath & "\""
set strCommandResult to (do shell script strCommandText) as text
log strCommandResult
on error
log "設定項目が見つかりません"
set strCommandResult to ""
end try
if strCommandResult contains "Hand" then
log "設定済みです"
else
set strCommandResult to ""
try
set strCommandText to "/usr/libexec/PlistBuddy -c \"Delete :DC:Selection:DefaultSelect:1\" \"" & strAcrobatReaderPlistPath & "\""
do shell script strCommandText
end try
delay 1
set strCommandText to "/usr/libexec/PlistBuddy -c \"Import :DC:Selection:DefaultSelect:1 '" & strImportDataPath & "'\" '" & strAcrobatReaderPlistPath & "'"
do shell script strCommandText
delay 1
set strCommandText to "/usr/libexec/PlistBuddy -c \"Print :DC:Selection:DefaultSelect:1\" \"" & strAcrobatReaderPlistPath & "\""
set strCommandResult to (do shell script strCommandText) as text
if strCommandResult contains "Hand" then
log "設定完了"
else
log "設定に失敗しました"
end if
set strCommandResult to ""
end if
end if
to doLogView()
tell application "System Events"
set listAppList to title of (every process where background only is false)
end tell
repeat with objAppList in listAppList
set strAppList to objAppList as text
if strAppList is "スクリプトエディタ" then
tell application "Script Editor"
if frontmost is true then
try
tell application "System Events" to click menu item "ログを表示" of menu "表示" of menu bar item "表示" of menu bar 1 of application process "Script Editor"
end try
end if
end tell
end if
end repeat
end doLogView