Skip navigation

Applescript - Adding "if" condition ICal  on/off alerts

462 Views 6 Replies Latest reply: Dec 1, 2012 3:07 AM by Ron60 RSS
Ron60 Calculating status...
Currently Being Moderated
Nov 27, 2012 11:07 AM

I'm using this script to turn off my ICal alerts while running scripts that conflict with schudule tasks.

 

I have serveral scripts that need to run throughout the day useing this process and some that need ICal alert on as well.

 

Is there a way to have this script not toggle on/off?  Currently, if I run another script while the ICal alert is off it will toggle ICal alerts to an "on" state.

 

Maybe an "if" statement - if "off" then quit,  --------------------------For those scripts which require ICal alerts to remain off.

And a "if" statement - if "off" then click the menu item to it's "on" state.  --For those scripts that require iCal alerts to be on.

 

I don't want it to be a dialog task. These scripts need to run in the background.

 

This is the script I'm currently using:

 

tell application "System Events" to tell process "iCal"

   --click menu item "Preferences…" of menu 1 of menu bar item "iCal" of menu bar 1
   click menu item 3 of menu 1 of menu bar item 2 of menu bar 1

 

   --click button " Advanced " of tool bar 1 of window 1
   click button 3 of tool bar 1 of window 1

 

   --click checkbox "Turn off all alarms" of window 1
   click checkbox 1 of window 1

 

   --click menu item "Close" of menu 1 of menu bar item "File" of menu bar 1
   click menu item 10 of menu 1 of menu bar item 3 of menu bar 1

end tell


tell application "iCal" to quit

 

Any help or advice would be greatly appriciated.  

 

Ron

iMac, Mac OS X (10.7.3)
  • Austin Kinsella1 Level 6 Level 6 (11,505 points)

    Could you give us an idea of the type of schedule taks that iCal alerts will conflict with? And indeed a general idea of the overall scheme.

  • Austin Kinsella1 Level 6 Level 6 (11,505 points)

    Thinking ...

  • Austin Kinsella1 Level 6 Level 6 (11,505 points)

    There is an old joke here where a tourist, somewhat lost, approaches a local at a crossroads and asks for directions to X. The man thinks for a while, scratches his head, takes his pipe out of his mouth, puts it back, thinks some more and eventually replies "Well, if I were you, I wouldn't start from here at all".

     

    I suspect iCal is not the solution, but rather launchd, the built-in scheduler. Something along these lines:

     

    put your schedule of (starttime, playlistname) in a text file

     

    write an Applescript which gets the name of the current playlist from iTunes and checks it against the scripts playlist property. If they are different ('cos you have used Big Button to change) exit. Otherwise check the file to see what playlist should be running now, and tell iTunes to change if necessary, remembering the playlist name in the playlist property and exit

     

    write a launchd agent to fie this script every 15 minutes (or whatever) (easy enough with property list editor, easier with eg lingon)

     

    There's probably a few wrinkles to iron out ...

Actions

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.