Easy Applescript question. I think.

Discussion in 'Mac Apps and Mac App Store' started by amberashby, Oct 25, 2004.

  1. amberashby macrumors 6502

    Joined:
    Nov 6, 2003
    #1
    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.
     
  2. SilentPanda Moderator emeritus

    SilentPanda

    Joined:
    Oct 8, 2002
    Location:
    The Bamboo Forest
    #2
    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.
     
  3. amberashby thread starter macrumors 6502

    Joined:
    Nov 6, 2003
    #3
    Not looking for a random desktop, but a way to change to a certain specified desktop without having to go to preferences every time.
     
  4. emw macrumors G4

    emw

    Joined:
    Aug 2, 2004
    #4
    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.
     
  5. scan300 macrumors 6502

    Joined:
    Mar 25, 2003
    Location:
    Melbourne, Australia
    #5
    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
    
     
  6. amberashby thread starter macrumors 6502

    Joined:
    Nov 6, 2003
  7. 5thplayer macrumors newbie

    Joined:
    Sep 14, 2008
    #7
    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:
     
  8. scan300 macrumors 6502

    Joined:
    Mar 25, 2003
    Location:
    Melbourne, Australia
    #8
    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)
     
  9. 5thplayer macrumors newbie

    Joined:
    Sep 14, 2008
    #9
    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
     

Share This Page