OOPS, I posted to Neil, not to the forum.
Le 05/01/2014 à 19:01, Neil Laubenthal <
email@hidden> a écrit :
On Jan 5, 2014, at 12:35 PM, Robert Poland <
email@hidden> wrote:
Neil,
Maybe we could help if we saw your old script.
Yeah, I guess that would help, wouldn’t it…:-)
Here’s what used to work…and I’m way not smart enough about Applescript to know why it doesn’t work anymore. IIRC it broke about the same time Spaces came out so that was probably Lion I guess.
tell application "System Events"
set my_desktop to value of (property list item "LastName" of ¬
property list item "default" of property list item ¬
"Background" of property list file ¬
((path to preferences as Unicode text) & ¬
"com.apple.desktop.plist"))
display dialog my_desktop
end tell
Here’s the error I get when running the script.
error "System Events got an error: Can’t get property list item \"default\" of property list item \"Background\" of property list file \"Brilliant3:Users:honeybear:Library:Preferences:com.apple.desktop.plist\"." number -1728 from property list item "default" of property list item "Background" of property list file "Brilliant3:Users:honeybear:Library:Preferences:com.apple.desktop.plist”
It was easy to understand what is wrong.
In the default container of the com.apple.desktop.plist Preferences file there is no property entitled LastName.
There are two ones which may be useful for you :
ImageFilePath
which contains the unix path of the picture in the format : /Users/yvankoenig/Pictures/ecsb_background_tile.png
NewImageFilePath
which contains the unix path of the picture in the format : ~/Pictures/ecsb_background_tile.png
Here is an edited version which would work with every system knowing the system attribute "sys2" :
(system attribute "sys2")
tell application "System Events"
if result > 6 then # was 8 in the mail sent to Neil
value of (property list item "ImageFilePath" of ¬
property list item "default" of property list item ¬
"Background" of property list file ¬
((path to preferences as Unicode text) & ¬
"com.apple.desktop.plist"))
set my_desktop to name of disk item result
else
set my_desktop to value of (property list item "LastName" of ¬
property list item "default" of property list item ¬
"Background" of property list file ¬
((path to preferences as Unicode text) & ¬
"com.apple.desktop.plist"))
end if
display dialog my_desktop
end tell
I don't have 10.6 available on a machine so I can't look if there was a property storing the pict pathname as there are in 10.7 and higher.
Yvan KOENIG (VALLAURIS, France) lundi 6 janvier 2014 10:22:16