Desktop Changer Script

I do a fair bit of image editing, so I wrote a small script to change the desktop pattern from the blue colour I like most of the time to a nuetral grey and also one to change it back.

To change to grey:

set SolidGrayMedium to (path to desktop pictures folder as Unicode text) & “Solid Colors:Solid Gray Medium.png”
tell application “Finder” to set desktop picture to file SolidGrayMedium

To change it back to blue:

set SmallRipples to (path to desktop pictures folder as Unicode text) & “Small Ripples.png”
tell application “Finder” to set desktop picture to file SmallRipples

I have a small problem with this script that I’d like assistance with if anyone who’s reading this can help. Basically, I wrote this script when I had a single monitor. I’m now lucky enough to have a double monitor set up. When I run the script it changes to pattern on the main screen but ignores the second screen. I though it should change both since they function as one big screen, but I obviously need to change the code slightly. Can anyone help?

:confused:

Hi Cloudwalker,

If you want to change the desktop picture on specific monitors, you need to use «System Events» instead of the Finder:


set picturefilepath to (((path to library folder) as Unicode text) & "Desktop Pictures:Plants:Agave.jpg")
tell application "System Events"
	tell desktop 1
		set picture to picturefilepath
	end tell
	tell desktop 2
		set picture to picturefilepath
	end tell
end tell

Thanks a lot for your help. This now works perfectly on my system.