Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

amberashby

macrumors 6502
Original poster
Nov 6, 2003
254
0
I've never used Applescript before, but I'm wondering if it could be used to perform this simple task. I would like to have an Applescript that would change my desktop background. Is this possible via Applescript?

Thanks.
 
I suppose possible... but OS X already has this functionality built in unless you need something more specific... just look under "Desktop" in your System Preferences. You can have it randomly select a desktop background for you in varying intervals.
 
Not looking for a random desktop, but a way to change to a certain specified desktop without having to go to preferences every time.
 
amberashby said:
Not looking for a random desktop, but a way to change to a certain specified desktop without having to go to preferences every time.

Do this:

Code:
tell application "Finder"
     set desktop picture to "<HD>:<Directory>:<image>"
end tell

HD = Name of your Hard Drive
Directory = Directory path of image (i.e., Users:User1:pictures)
Image = image name

Edit: If you wanted to be more complex, you could have it ask which desktop you wanted as well.
 
emw said:
Do this:

Code:
tell application "Finder"
     set desktop picture to "<HD>:<Directory>:<image>"
end tell

To make the above script so you can drag and drop an image, use the following code and save it as an application. It will become a droplet.
Code:
on open (myRef)
	
	tell application "Finder"
		set myPicture to myRef as alias
		set desktop picture to myPicture		
	end tell
	
end open

Note: these applescripts only work if you have 'Automatically change picture' set to off in the desktop preference pane.

If you want to make an application that you can browse for an image use the following code:
Code:
tell application "Finder"
	choose file
	set myPicture to result
	set desktop picture to myPicture	
end tell
 
error code

i have the following code

tell application "Finder"
set desktop picture to "<bob>:<Users:administrator:pictures>:<Earth Horizon.jpg>"
end tell

but it keeps telling me that it it "cant make **** into a file type"


can anyone tell me what im doing wrong?

i was also wondering, how can i get the script to run for more than 1 user as in i logged in as the administrator and i want it to change the desktop picture for all users


im using 10.5.4 in applescript on a intel mac

thanks
5thplayer:confused::confused::confused::confused:
 
i have the following code

tell application "Finder"
set desktop picture to "<bob>:<Users:administrator:pictures>:<Earth Horizon.jpg>"
end tell

but it keeps telling me that it it "cant make **** into a file type"

You don't need the < and > characters in your path.
it should be set desktop picture to "bob:Users:administrator:pictures:Earth Horizon.jpg"

You can't change the picture for all users without logging in to each user and running the script. You can however get all users to set their desktop picture to an image located in the shared folder. Volume:Users:Shared: Then just replace the image when you want, keeping the filename the same (only the image changes). Each user account will have the new desktop image displayed when they log in. (No need for applescript here)
 
thanks

thanks scan300 ill try your suggestion, i work in a school so i wanted to see if there was an easy way to do this in a fast way,

thanks
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.