Created
January 21, 2019 03:01
-
-
Save spuder/c92dd0637ce85b6960b81e1415d7c52e to your computer and use it in GitHub Desktop.
Apple Script to print out the entire week in calendar
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
on run {input, parameters} | |
-- | |
tell application "Calendar" to quit | |
delay 2 | |
tell application "Calendar" | |
activate | |
end tell | |
-- Press ⌘P | |
delay 0.5 | |
set timeoutSeconds to 2.0 | |
set uiScript to "keystroke \"p\" using command down" | |
my doWithTimeout(uiScript, timeoutSeconds) | |
-- Choose Days to print | |
delay 0.5 | |
set timeoutSeconds to 2.0 | |
set uiScript to "click pop up button 2 of window \"Print\" of application process \"Calendar\"" | |
my doWithTimeout(uiScript, timeoutSeconds) | |
-- Week | |
delay 0.5 | |
set timeoutSeconds to 2.0 | |
set uiScript to "click menu item \"Week\" of menu 1 of pop up button 2 of window \"Print\" of application process \"Calendar\"" | |
my doWithTimeout(uiScript, timeoutSeconds) | |
-- Click the “<fill in title>” checkbox. | |
delay 0.5 | |
set timeoutSeconds to 2.0 | |
set uiScript to "click checkbox 1 of row 2 of outline 1 of scroll area 1 of window \"Print\" of application process \"Calendar\"" | |
my doWithTimeout(uiScript, timeoutSeconds) | |
-- Click the “<fill in title>” checkbox. | |
delay 1 | |
set timeoutSeconds to 2.0 | |
set uiScript to "click checkbox 1 of row 3 of outline 1 of scroll area 1 of window \"Print\" of application process \"Calendar\"" | |
my doWithTimeout(uiScript, timeoutSeconds) | |
-- Click the “<fill in title>” checkbox. | |
delay 1 | |
set timeoutSeconds to 2.0 | |
set uiScript to "click checkbox 1 of row 4 of outline 1 of scroll area 1 of window \"Print\" of application process \"Calendar\"" | |
my doWithTimeout(uiScript, timeoutSeconds) | |
-- Click the “<fill in title>” checkbox. | |
delay 1 | |
set timeoutSeconds to 2.0 | |
set uiScript to "click checkbox 1 of row 6 of outline 1 of scroll area 1 of window \"Print\" of application process \"Calendar\"" | |
my doWithTimeout(uiScript, timeoutSeconds) | |
-- Click the “<fill in title>” checkbox. | |
delay 1 | |
set timeoutSeconds to 2.0 | |
set uiScript to "click checkbox 1 of row 9 of outline 1 of scroll area 1 of window \"Print\" of application process \"Calendar\"" | |
my doWithTimeout(uiScript, timeoutSeconds) | |
-- Click the “<fill in title>” checkbox. | |
delay 1 | |
set timeoutSeconds to 2.0 | |
set uiScript to "click checkbox 1 of row 10 of outline 1 of scroll area 1 of window \"Print\" of application process \"Calendar\"" | |
my doWithTimeout(uiScript, timeoutSeconds) | |
-- Click the “Continue” button. | |
delay 1 | |
set timeoutSeconds to 2.0 | |
set uiScript to "click UI Element \"Continue\" of window \"Print\" of application process \"Calendar\"" | |
my doWithTimeout(uiScript, timeoutSeconds) | |
-- Make a selection from the popupbutton. | |
delay 1 | |
set timeoutSeconds to 2.0 | |
set uiScript to "click pop up button 1 of window \"Print\" of application process \"Calendar\"" | |
my doWithTimeout(uiScript, timeoutSeconds) | |
-- Spencer & Amanda Laser | |
delay 1 | |
set timeoutSeconds to 2.0 | |
set uiScript to "click menu item \"Spencer & Amanda Laser\" of menu 1 of pop up button 1 of window \"Print\" of application process \"Calendar\"" | |
my doWithTimeout(uiScript, timeoutSeconds) | |
-- Click the “Print” button. | |
delay 1 | |
set timeoutSeconds to 2.0 | |
set uiScript to "click UI Element \"Print\" of window \"Print\" of application process \"Calendar\"" | |
my doWithTimeout(uiScript, timeoutSeconds) | |
return input | |
end run | |
on doWithTimeout(uiScript, timeoutSeconds) | |
set endDate to (current date) + timeoutSeconds | |
repeat | |
try | |
run script "tell application \"System Events\" | |
" & uiScript & " | |
end tell" | |
exit repeat | |
on error errorMessage | |
if ((current date) > endDate) then | |
error "Can not " & uiScript | |
end if | |
end try | |
end repeat | |
end doWithTimeout |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment