安装 macOS-sierra 苹果脚本后,在取景器中显示实际墙纸不再工作

After installing macOS-sierra apple script showing actual wallpaper in finder not working any longer

我曾经使用以下 apple 脚本在我的显示器(双模式)上找出实际的墙纸图像并在 finder 中显示它。在 El Capitan 下,脚本运行良好。安装 Mac OS Sierra 后,脚本显示错误消息

"error "„Finder“ hat einen Fehler erhalten: Die Routine kann Objekte dieser Klasse nicht bearbeiten." number -10010"

英文翻译:

"error "„Finder“ received an error: The routine cannot work with objects of this class.“ number - 10010". The object which is highlighted in the script is "reveal rotationImage"

我不是苹果脚本专家。不幸的是,我在网上找不到任何帮助。可能是什么问题?

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