Skip to content

Instantly share code, notes, and snippets.

@spuder
Created December 21, 2023 17:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spuder/c6fb57b918e20501c062c6a86e35c956 to your computer and use it in GitHub Desktop.
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)
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
@spuder
Copy link
Author

spuder commented Dec 21, 2023

What this does

  1. Opens Calendar
  2. Presses CMD + P
  3. Changes View to Month
  4. Unchecks all Calendars (Birthdays, ect...)
  5. Unchecks All-day events, timed events, ect...
  6. Checks Black and White
  7. Prints to default printer
Screenshot 2023-12-21 at 10 34 58 AM

How to use

  1. Open applescript
  2. Paste in the code
  3. Press Play button
  4. Don't touch your keyboard for a few seconds
  5. Check your printer, a paper should be printed out

Screenshot 2023-12-21 at 10 36 35 AM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment