applescript 查找墙纸图像不再在 Mac OS Mojave 下工作
applescript to find wallpaper image not working under Mac OS Mojave anymore
我曾经使用两个 applescripts 在 Mac OS High Sierra 下从桌面 1 和桌面 2(双显示器模式)找出实际墙纸图像的文件名。一个用于主显示器的脚本,另一个用于第二个显示器的脚本。在 Mac OS Mojave 下,只有桌面 1 的脚本仍在运行。桌面 2 的脚本不再有效。试图找到问题,但找不到解决方案。我不是一位经验丰富的 applescript 作家。希望有人能帮忙。
桌面 1(主显示器)的脚本 1:
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=1 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
桌面 2(第二台显示器)的脚本 2:
tell application "System Events"
set posix_path to (pictures folder of desktop 2)
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
脚本的预期结果是 finder 打开 window 显示实际墙纸图像的文件。它适用于 script1 但不适用于 script2
我发现了问题。在 High Sierra 和 Mojave 之间的某处,桌面 2 的活动墙纸图像的 preferences.picture_id
编号已更改。
在 High Sierra 中,id
是 preferences.picture_id=5
,在 Mojave 中是 preferences.picture_id=7
。
也许这对其他人有帮助。
我曾经使用两个 applescripts 在 Mac OS High Sierra 下从桌面 1 和桌面 2(双显示器模式)找出实际墙纸图像的文件名。一个用于主显示器的脚本,另一个用于第二个显示器的脚本。在 Mac OS Mojave 下,只有桌面 1 的脚本仍在运行。桌面 2 的脚本不再有效。试图找到问题,但找不到解决方案。我不是一位经验丰富的 applescript 作家。希望有人能帮忙。
桌面 1(主显示器)的脚本 1:
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=1 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
桌面 2(第二台显示器)的脚本 2:
tell application "System Events"
set posix_path to (pictures folder of desktop 2)
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
脚本的预期结果是 finder 打开 window 显示实际墙纸图像的文件。它适用于 script1 但不适用于 script2
我发现了问题。在 High Sierra 和 Mojave 之间的某处,桌面 2 的活动墙纸图像的 preferences.picture_id
编号已更改。
在 High Sierra 中,id
是 preferences.picture_id=5
,在 Mojave 中是 preferences.picture_id=7
。
也许这对其他人有帮助。