Welcome to MacForumz.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Change the Desktop Background with Applescript

 
   Macintosh computer (Home) -> Apple Scripts RSS
Next:  Email, PDF and Filemaker Pro  
Author Message
spacemancw

External


Since: Nov 11, 2003
Posts: 31



(Msg. 1) Posted: Sun Sep 14, 2003 1:07 pm
Post subject: Change the Desktop Background with Applescript
Archived from groups: alt>comp>lang>applescript (more info?)

iBook
OS X 10.2.6

Hi

I want to use applescript to change the desktop pictures on my Mac.
I have a folder of pics that I want as my random backgrounds at a
certain time of the day and another folder of pics for the rest of the
day.

I anticipate running a cron job (with UNIX) that fires off an
applescript which will set the folder for the background pics ... and
to set to randomly change every 15 or 30 mins.

.... then the cron will run again and change it back to the other
folder later in the day.

I can do the cron and the bash script to figure out the time of day
etc .. I just need to know the syntax for the applescript to change
desktop background properties.

Thanx

Roger McCarrick

 >> Stay informed about: Change the Desktop Background with Applescript 
Back to top
Login to vote
spacemancw

External


Since: Nov 11, 2003
Posts: 31



(Msg. 2) Posted: Sun Sep 14, 2003 10:16 pm
Post subject: Re: Change the Desktop Background with Applescript [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

OK .. figure it out
... for those who would also like to do this:

Get UI Scripting Beta at <a rel="nofollow" style='text-decoration: none;' href="http://www.apple.com/applescript/GUI/" target="_blank">http://www.apple.com/applescript/GUI/</a>
and Script Editor 2.0 Beta at
<a rel="nofollow" style='text-decoration: none;' href="http://www.apple.com/applescript/script_editor/beta.html" target="_blank">http://www.apple.com/applescript/script_editor/beta.html</a>
Check the "Enable Access for Assistive Devices" in the Universal
Access of System Preferences

here's the code for Script 1
--------------------
tell application "System Preferences"
  activate
end tell

tell application "System Events"
  tell process "System Preferences"
   click menu item "Desktop" of menu "View" of menu bar 1
   if my wait4window("Desktop") is false then return false
   tell window 1
    tell pop up button 1
    click
    tell menu 1
    if the name of every menu item contains "Apple Background Images"
then
    click menu item "Apple Background Images"
    delay 1
    end if
    end tell
    end tell
   end tell
  end tell
end tell

ignoring application responses
  tell application "System Preferences" to quit
end ignoring

on wait4window(this_title)
  tell application "System Events"
   tell process "System Preferences"
    repeat with i from 1 to 60
    if the name of window 1 is this_title then return true
    delay 1
    end repeat
   end tell
  end tell
  return false
end wait4window
--------------------

My cron looks like this

0 9 * * * /Users/spaceman/script1.app > /dev/null 2>&1
0 17 * * * /Users/spaceman/script2.app > /dev/null 2>&1

So at 9am each day the cron fires off script 1 and sets Apple
Background Images folder as the image folder. Then at 17:00 the cron
fires off script2 and sets my other, more exciting pictures as desktop
images.

works like a charm

Roger


(spacemancw) wrote in message ...
 > iBook
 > OS X 10.2.6
 >
 > Hi
 >
 > I want to use applescript to change the desktop pictures on my Mac.
 > I have a folder of pics that I want as my random backgrounds at a
 > certain time of the day and another folder of pics for the rest of the
 > day.
 >
 > I anticipate running a cron job (with UNIX) that fires off an
 > applescript which will set the folder for the background pics ... and
 > to set to randomly change every 15 or 30 mins.
 >
 > ... then the cron will run again and change it back to the other
 > folder later in the day.
 >
 > I can do the cron and the bash script to figure out the time of day
 > etc .. I just need to know the syntax for the applescript to change
 > desktop background properties.
 >
 > Thanx
 >
 > Roger McCarrick

 >> Stay informed about: Change the Desktop Background with Applescript 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
New to Applescript - Hello, I'm brand new to Applescript - I've done a lot with VBS but never touched Applescript. Are there some good script repositories online? AppleScript Editors? Manuals? Any help will be greatly appreciated!!! TIA, Bill bill@2burkes.com

Applescript RSS - Is there any way to acquire an RSS feed using Applescript? I'd like to be able to specify the RSS URL, then have Applescript consume the most recent 5 entries. Thanks, A

Use applescript in Keynote - Am trying to use applescript to modify the color of a selected text element on a slide in Keynote. is it possible to have a script that can set the font, size, color of a selected text in keynote using applescript. The dictionary mentions about a..

AppleScript 2.2 (Lion) - Hello, Lion's AppleScript is version 2.2. Apple has yet to make the release notes available, but some new features are presented here: http://www.macosxautomation.com/lion/index.html Patrick -- Patrick Stadelmann <Patrick.Stadelmann@unine.ch>

Leopard, Firefox & Applescript - Can anyone tell me why a script I wrote to log in to my bank no longer works in Firefox since I installed Leopard? Can it by fixed? Thanks
   Macintosh computer (Home) -> Apple Scripts All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]