在安装了Macos-Sierra Apple脚本后,显示了Finder中实际墙纸不再工作



我曾经使用以下Apple脚本在我的监视器(二模式)上查找实际壁纸图像并在Finder中显示。在El Capitan下,脚本正常。我安装Mac OS Sierra后,脚本显示错误消息

"错误"„ Finder"帽子Einen Fehler Erhalten:Die常规Kann objekte Dieser klasse nicht bearbeiten。"数字-10010"

英语翻译:

"错误"„ finder"收到了一个错误:例程无法与此类的对象一起使用。"数字-10010"。脚本中突出显示的对象是"显示rotationImage"

我不是Apple脚本专家。不幸的是,我在网络上找不到任何帮助。有什么问题?

tell application "System Events"
    set posix_path to (pictures folder of desktop 1)
    set picPath to (POSIX file posix_path) as string
end tell
set thePictures to (do shell script "sqlite3 ~/Library/Application\ Support/Dock/desktoppicture.db "SELECT data.value FROM preferences INNER JOIN data on preferences.key=16 and preferences.picture_id=5 and preferences.data_id=data.ROWID"")
set fullPath to picPath as string
set rotationImage to fullPath & thePictures
tell application "Finder"
    reveal rotationImage
    activate
end tell
tell application "Finder"
    get selection
    repeat with moose in result
        if original item of moose exists then
            reveal original item of moose
        end if
    end repeat
end tell

脚本在我的计算机上工作,即使在Sierra上,失败的原因也可能是reveal期望文件参考而不是文字字符串。

这是您脚本的略微优化版本:

tell application "System Events"
    set posix_path to (pictures folder of desktop 1)
    set picPath to (POSIX file posix_path) as string
end tell
set thePictures to (do shell script "sqlite3 ~/Library/Application\ Support/Dock/desktoppicture.db "SELECT data.value FROM preferences INNER JOIN data on preferences.key=16 and preferences.picture_id=5 and preferences.data_id=data.ROWID"")
set fullPath to picPath as string
set rotationImage to fullPath & thePictures
tell application "Finder"
    try
        set aliasItem to item rotationImage
        if class of aliasItem is alias file then
            reveal original item of aliasItem
        end if
    end try
end tell

最新更新