我确实有以下两个以不同方式做同样事情的应用程序。脚本在OS X Yosemite 10.10.3上查找并显示当前壁纸的路径和图像名称,然后在finder中显示原始图像。
我在双监视器模式下工作,所以我必须找到主监视器和辅助监视器的当前壁纸。在我的脚本中,我使用“桌面1”和“桌面2”或主要监视器的“preferences.picture_id = 3”或辅助监视器的“preferences.picture_id = 5”来处理不同的监视器。
这两个脚本原则上都在工作,但由于某种原因,这两个脚本有时不适用于两个监视器(主要和次要),而只适用于其中一个。有时是小学但不是中学,有时反之亦然。
如果脚本不起作用,则显示错误号10010。
我在网上搜了几天,我尝试了各种不同的东西,我找不到问题。我不得不说我不是一个苹果专家。非常感谢帮助。
亲切的问候,
彼得
以下是两个脚本:
脚本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
答案 0 :(得分:0)
如果您要尝试的是显示桌面的当前壁纸,则只需使用此代码:
tell application "System Events"
repeat with current_desktop in desktops
set picPath to POSIX file (picture of current_desktop) as string
tell application "Finder" to reveal picPath
end repeat
end tell