【发布时间】:2015-05-27 14:06:42
【问题描述】:
我确实有以下两个苹果脚本,它们以不同的方式做同样的事情。脚本在 OS X Yosemite 10.10.3 上查找并显示当前壁纸的路径和图像名称,然后在 finder 中显示原始图像。
我在双显示器模式下工作,所以我必须找到主显示器和辅助显示器的当前壁纸。在我的脚本中,我使用“桌面 1”和“桌面 2”或“preferences.picture_id=3”作为主监视器或“preferences.picture_id=5”作为辅助监视器来处理不同的监视器。
这两个脚本原则上都可以工作,但由于某些原因,两个脚本有时不能同时用于两个监视器(主要和次要),而只能用于其中一个。有时是小学而不是中学,有时反之亦然。
如果脚本不工作,它们会显示错误号 10010。
我在网上搜索了几天,尝试了各种不同的方法,但我找不到问题所在。我不得不说我不是applescripts 专家。非常感谢您的帮助。
亲切的问候,
彼得
这是两个脚本:
脚本 1:
tell application "System Events"
set posix_path to (pictures folder of desktop 2)
set picPath to (POSIX file posix_path) as string
end tell
tell application "System Events"
tell current desktop
if picture rotation = 0 then
tell application "System Events"
set posix_path to (picture of desktop 2)
set thePicture to (POSIX file posix_path) as string
end tell
tell application "Finder"
reveal thePicture
activate
end tell
else
set thePictures to (do shell script "sqlite3 ~/Library/Application\\ Support/Dock/desktoppicture.db \"SELECT * FROM data\" | sed -n '$p'")
set fullPath to picPath as string
set rotationImage to fullPath & thePictures
tell application "Finder"
reveal rotationImage
activate
end tell
end if
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
end tell
脚本 2:
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=3 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
【问题讨论】:
-
所以,您只是想显示各种桌面的壁纸位置?
标签: image applescript wallpaper multiple-monitors