1

I need an applescript that will find the path to the desktop picture used in Desktop 2. As this isn't the current desktop the code below doesn't work.

tell application "Finder"
    set DesktopPath to desktop picture as string
end tell

Is there anyway to easily automatically find the path to the picture in desktop 2?

runnning el capitan

1
  • From MacOS 10.12 Sierra on, a lot of things have changed in System. I am using High Sierra 10.13.6 and there is no "desktop 2" in a list of EVERY desktop, but only the currently used one. . . . To get desktop picture I use: . . . tell application "System Events" to set PicsName to (picture of current desktop as text) . . . which will deliver: . . . "/Library/Desktop Pictures/Aqua Blue1024.jpg" Nov 23, 2018 at 14:01

1 Answer 1

1

This works for me:

tell application "System Events"
set tlst to a reference to every desktop
--set picture of item 1 of tlst to newtop  -- display 1
--set picture of item 2 of tlst to newtop -- display 2
set z to (picture of item 2 of tlst) as text
end tell
return z

The commented out lines are for setting desktop pic on one display or the other. newtop is obviously preset, or the result of

set newtop to choose file
4
  • System Events got an error: Can’t get item 2 of every desktop. Invalid index. I seem to get this error?
    – cjeccjec
    Mar 20, 2016 at 1:22
  • I'm not seeing that error. OS X 10.11.3 Script Editor 2.81 AppleScript 2.5 Have you got the "set z..." bit inside your tell block? I can get errors similar to what you describe if I move that line outside the tell. Mar 20, 2016 at 1:27
  • The code is copied as is. I'm checking on another computer atm. Edit: On another computer with the exact script it comes up with the same error.
    – cjeccjec
    Mar 20, 2016 at 1:33
  • I recall possibly seeing this script to be used for different desktops on different monitors. The desktops I mean are the ones with numbers when pressing f3 next to the dashboard.
    – cjeccjec
    Mar 20, 2016 at 1:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .