Created
December 21, 2023 17:34
-
-
Save spuder/c6fb57b918e20501c062c6a86e35c956 to your computer and use it in GitHub Desktop.
Apple Script to print out 1 month calendar, removing all digital calendars (e.g birthdays/holidays)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tell application "Calendar" to quit | |
delay 2 | |
tell application "Calendar" | |
activate | |
end tell | |
tell application "System Events" | |
delay 2 -- Wait for Calendar to activate | |
key down {command} | |
keystroke "p" -- Command + P to print | |
key up {command} | |
delay 5 -- Wait for the print dialog to open | |
tell process "Calendar" | |
tell window "Print" | |
-- Select "Month" from the view pop-up menu | |
tell pop up button 2 -- This might need to be adjusted | |
click -- Click the pop-up menu to show options | |
delay 1 -- Wait for the menu to populate | |
click menu item "Month" of menu 1 -- Select "Month" | |
end tell | |
delay 1 | |
-- Uncheck all checkboxes in the 'outline' within 'scroll area' | |
tell scroll area 1 | |
set checkboxRows to every row of outline 1 | |
repeat with aRow in checkboxRows | |
try | |
set theCheckbox to checkbox 1 of aRow | |
if value of theCheckbox as boolean then | |
click theCheckbox -- Uncheck the checkbox | |
end if | |
delay 0.1 -- Small delay | |
on error errMsg number errNum | |
log "Error with row: " & (aRow's description) & " | Error: " & errMsg & " | Number: " & errNum | |
end try | |
end repeat | |
end tell | |
delay 1 | |
-- Uncheck "All-day events" | |
tell checkbox "All-day events" -- Adjust as necessary | |
if value is 1 then | |
click | |
end if | |
end tell | |
delay 1 | |
-- Uncheck "Timed events" | |
tell checkbox "Timed events" -- Adjust as necessary | |
if value is 1 then | |
click | |
end if | |
end tell | |
delay 1 | |
-- Uncheck "Calendar keys" | |
tell checkbox "Calendar keys" -- Adjust as necessary | |
if value is 1 then | |
click | |
end if | |
end tell | |
delay 1 | |
-- Check "Black and white" | |
tell checkbox "Black and white" -- Adjust as necessary | |
if value is 0 then | |
click | |
end if | |
end tell | |
delay 1 | |
click button "Continue" | |
end tell | |
delay 1 | |
keystroke return -- May not be needed if "Continue" button does the job | |
end tell | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What this does
How to use