You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Automate Print Dialog with AppleScript in Lion - Checkbox Problem

Folks,

I'd like to automate a daily printing of an ical Calendar.

I have the following applescript.


tell application "iCal"


view calendarat (my (current date))


switch viewtoday view


activate

tell application "System Events"


keystroke "p" usingcommand down


delay 1 -- (seconds)

if value of checkbox "Calendar Keys" is not 0 then

click checkbox "Calendar Keys"

end if


end tell


end tell


However, I get the following error:


System Events got an error: Can’t get checkbox "Calendar Keys".


I've used the Accessibility Inspector, and it tells me that the check box is called 'Calendar Keys", so I'm not sure what's going wrong.


Any ideas?


Thanks,

Zvi

Posted on Sep 23, 2011 7:37 AM

Reply
Question marked as Top-ranking reply

Posted on Sep 23, 2011 1:17 PM

Try this:


tell application "iCal"

view calendarat (my (current date))

switch viewtoday view

activate

tell application "System Events"

keystroke "p" usingcommand down

delay 1 -- (seconds)

tell process "iCal"

tell window "Print"

if value of checkbox "Calendar Keys" is not 0 then

click checkbox "Calendar Keys"

end if

end tell

end tell

end tell

end tell

8 replies
Question marked as Top-ranking reply

Sep 23, 2011 1:17 PM in response to zbiener

Try this:


tell application "iCal"

view calendarat (my (current date))

switch viewtoday view

activate

tell application "System Events"

keystroke "p" usingcommand down

delay 1 -- (seconds)

tell process "iCal"

tell window "Print"

if value of checkbox "Calendar Keys" is not 0 then

click checkbox "Calendar Keys"

end if

end tell

end tell

end tell

end tell

Jul 17, 2013 1:38 AM in response to zbiener

I know it's been a while since this thead but I'm so dull with scripting and stuff — do you have an update to this script. I think there have been changes since 2011, it's no longer iCal but Calendar and additionally their might another window to process in the script (I hope I'm saying that all right) and was wondering if you might a fix for this. It woudl GREATLY appreciated.


Best regards 🙂

Nov 11, 2013 6:54 AM in response to heathhines

it pretty much works as Pierre wrote it:


tell application "Calendar"

activate

view calendar at (my (current date))

switch view to day view

tell application "System Events"

keystroke "p" using command down

delay 1 -- (seconds)

tell process "Calendar"

tell window "Print"

if value of checkbox "Calendar Keys" is not 0 then

click checkbox "Calendar Keys"

end if

end tell

end tell

end tell

end tell



OS X 10.9

Calendar 7.0 (1835)

Dec 17, 2013 10:54 PM in response to Gregory Rivers

Thank you so much. I'm now just getting to this (oy!). So sorry for the delay of thanks! But it seems to stop at at these windows; the only things left that need to happen is that the "Continue" button needs to be clicked and then, in the next window that comes up, "Print" needs to be clicked. If you can help at all in anyway, I (and my life, lol) would be extremely, extremely grateful.


User uploaded fileUser uploaded file

Dec 18, 2013 5:42 AM in response to heathhines

The following script seems to do the trick, although you must wait several seconds before the "Print" button is finally clicked.


tell application "Calendar"

view calendarat (my (current date))

switch viewtoweek view-- day, week or month view

activate

tell application "System Events"

keystroke "p" using command down

tell process "Calendar"

repeat until exists window "Print"

delay 0.1

end repeat

tell window "Print"

click button "Continue"

repeat until exists button "Print"

delay 0.1

end repeat

click button "Print"

end tell

end tell

end tell

end tell



OS X 10.9.1

Calendar 7.0 (1835.1)


Message was edited by: Pierre L.

Automate Print Dialog with AppleScript in Lion - Checkbox Problem

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.