This is my code so far. Anyone know how I can check the checkbox “Alle Erinnerungen deaktivieren” (http://qkpic.com/0350f German UI)?
tell application "iCal"
activate
end tell
tell application "System Events"
keystroke "," using command down
keystroke tab using shift down
keystroke " "
-- Alle Erinnerungen deaktivieren wählen
end tell
-- tell application "iCal"
-- quit
-- end tell
Since you’re using German, I referenced each item by index. I also included the equivalent reference by element name for each line in English too in case that’s helpful.
tell application "iCal" to activate
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
----------------
-- This script prepares my Mac for presentations by
-- 1) turning off iCal alarms
-- 2) turning on Caffeine (http://lightheadsw.com/caffeine/)
--
-- by ptujec 08/10/09
--
-- using
-- http://macscripter.net/viewtopic.php?pid=116717#p116717
-- by Hank
----------------
tell application "iCal" to activate
tell application "System Events" to tell process "iCal"
click menu item 3 of menu 1 of menu bar item 2 of menu bar 1
click button 3 of tool bar 1 of window 1
end tell
tell me to activate
display dialog "Change current settings?" buttons ["No", "Ok"] default button "Ok"
if button returned of result is "No" then
tell application "iCal" to quit
else
tell application "System Events" to tell process "iCal"
click checkbox 1 of window 1
end tell
tell application "iCal" to quit
end if
tell application "Caffeine" to activate
tell application "Caffeine" to turn on
2. Turn iCal alarms on again and Caffeine off (with option to quit Caffeine)
----------------
-- This script sets my Mac back to "normal" (after a presentation) by
-- 1) turning on iCal alarms
-- 2) turning off Caffeine (http://lightheadsw.com/caffeine/)
--
-- by ptujec 08/10/09
--
-- using
-- http://macscripter.net/viewtopic.php?pid=116717#p116717
-- by Hank
----------------
tell application "iCal" to activate
tell application "System Events" to tell process "iCal"
click menu item 3 of menu 1 of menu bar item 2 of menu bar 1
click button 3 of tool bar 1 of window 1
end tell
tell me to activate
display dialog "Change current settings?" buttons ["No", "Ok"] default button "Ok"
if button returned of result is "No" then
tell application "iCal" to quit
else
tell application "System Events" to tell process "iCal"
click checkbox 1 of window 1
end tell
tell application "iCal" to quit
end if
tell application "Caffeine" to activate
tell application "Caffeine" to turn off
tell application "Finder" to activate
tell me to activate
display dialog "Quit Caffeine?"
tell application "Caffeine" to quit
3. Turn iCal alarms off/on
----------------
-- This script activate or disactivates iCal alarms
--
-- Source:
-- http://macscripter.net/viewtopic.php?pid=116717#p116717
-- by Hank
--
-- adapted by ptujec 08/10/09
----------------
tell application "iCal" to activate
tell application "System Events" to tell process "iCal"
click menu item 3 of menu 1 of menu bar item 2 of menu bar 1
click button 3 of tool bar 1 of window 1
end tell
tell me to activate
display dialog "Change current settings?" buttons ["No", "Ok"] default button "Ok"
if button returned of result is "No" then
tell application "iCal" to quit
else
tell application "System Events" to tell process "iCal"
click checkbox 1 of window 1
end tell
tell application "iCal" to quit
end if
I included a dialog to make sure the alarms are not already turned off, because the script would turn them on again automatically … and vice versa. Would be nice if the script could detect the state of the checkbox instead. But my tries failed.
you can let AppleScript ask for the status of a checkbox by looking for its value. In this case:
tell application "System Events" to tell process "iCal"
set check to value of checkbox 1 of window 1
end tell
If the variable “check” is 0 the checkbox ist not checked, if it is 1 the checkbox is checked.
Based on this and on this thread so far (thx for the groundwork) I have manipulated the Script for my personal (german) needs:
----------------
-- Dieses Script ändert den Status der Einstellung
-- "Alle Erinnerungen deaktivieren" in iCal (3.0.8)
--
-- Quelle:
-- http://macscripter.net/viewtopic.php?pid=116717#p116717
-- von Hank
--
-- Angepasst:
-- http://macscripter.net/viewtopic.php?id=30031
-- von ptujec 10. Aug. 2009
--
-- Ergänzt von Lord of the Macs 18. Sept. 2009
----------------
tell application "iCal" to activate
tell application "System Events" to tell process "iCal"
click menu item 3 of menu 1 of menu bar item 2 of menu bar 1
click button 3 of tool bar 1 of window 1
end tell
tell me to activate
tell application "System Events" to tell process "iCal"
set check to value of checkbox 1 of window 1
end tell
if check = 0 then
display dialog "Erinnerungen sind AKTIV!" buttons ["Abbrechen", "Deaktivieren"] default button "Deaktivieren"
if button returned of result is "Abbrechen" then
tell application "iCal" to quit
else
tell application "System Events" to tell process "iCal"
click checkbox 1 of window 1
end tell
tell application "iCal" to quit
end if
else
display dialog "Erinnerungen sind NICHT aktiv!" buttons ["Abbrechen", "Wieder aktivieren"] default button "Wieder aktivieren"
if button returned of result is "Abbrechen" then
tell application "iCal" to quit
else
tell application "System Events" to tell process "iCal"
click checkbox 1 of window 1
end tell
tell application "iCal" to quit
end if
end if
My copies of iCal are older versions and don’t have the “Turn off all alarms” setting. But it’s possible with them to change the “Turn off alarms when iCal is not open” setting by writing directly to iCal’s preference file:
do shell script "defaults write com.apple.iCal 'Disable background alarms' 1" -- Check the box.
do shell script "defaults write com.apple.iCal 'Disable background alarms' 0" -- Uncheck the box.
These have to be executed while iCal’s not open, so they save having to open iCal ” and of course save having to use GUI Scripting.
If you run the following, perhaps you might find some key corresponding to “Turn off all alarms”, which you could then use instead of ‘Disable background alarms’ in the lines above. However, I don’t know for sure.