DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Set Desktop Background Droplet

01.28.2006
| 7351 views |
  • submit to reddit
        -- This script should be run as a droplet
-- It expects that an image is dropped on it's icon


-- 
-- The on run handler is called if the user has double clicked the icon
--
on run
	display dialog "Please drop an image file on this Icon to set it as the desktop background"
end run


--
-- The on open handler is called when the user drags and drops  afile on the icon
--
on open draggeditems
	set imageFile to last item of draggeditems
	
	tell application "Finder"
		select window of desktop
		try
			set desktop picture to file (imageFile as text)
		on error
			display dialog "Invalid image file."
		end try
	end tell
	
end open