-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPublish Calendars to iCloud.applescript
More file actions
166 lines (146 loc) · 3.13 KB
/
Publish Calendars to iCloud.applescript
File metadata and controls
166 lines (146 loc) · 3.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
-- Publishes the Calendars as Public
tell application "Calendar"
activate
end tell
tell application "System Events"
tell process "Calendar"
keystroke "f" using command down
delay 2
keystroke tab
delay 2
key code 126 using {option down}
delay 2
repeat with i from 1 to 35
key code 125
delay 2
tell menu bar 1
tell menu bar item "Edit"
tell menu "Edit"
click
delay 2
tell UI element 15
click
delay 2
end tell
end tell
end tell
end tell
tell window 1
tell splitter group 1
tell splitter group 1
tell scroll area 1
tell outline 1
tell row (i + 2)
tell pop over 1
set shareCalendar to checkbox 1
set doneButton to button "Done"
click shareCalendar
delay 2
click doneButton
delay 2
keystroke tab
delay 2
end tell
end tell
end tell
end tell
end tell
end tell
end tell
end repeat
end tell
end tell
tell application "Calendar"
activate
end tell
set calendarURLs to {}
tell application "System Events"
tell process "Calendar"
keystroke "f" using command down
delay 2
keystroke tab
delay 2
key code 126 using {option down}
delay 2
repeat with i from 1 to 35
key code 125
delay 2
keystroke "i" using command down
delay 2
tell window 1
tell sheet 1
set calendarName to value of text field 1
tell scroll area 1
tell text area 1
set theURL to value
end tell
end tell
end tell
end tell
keystroke return
delay 2
set end of calendarURLs to {calendarName, theURL}
end repeat
end tell
end tell
-- Grabs the published calendars and writes the URLs to a numbers document
tell application "Calendar"
activate
end tell
set calendarURLs to {}
tell application "System Events"
tell process "Calendar"
keystroke "f" using command down
delay 2
keystroke tab
delay 2
key code 126 using {option down}
delay 2
repeat with i from 1 to 35
key code 125
delay 2
keystroke "i" using command down
delay 2
tell window 1
tell sheet 1
set calendarName to value of text field 1
tell scroll area 1
tell text area 1
set theURL to value
end tell
end tell
end tell
end tell
keystroke return
delay 2
set end of calendarURLs to {calendarName, theURL}
end repeat
end tell
end tell
tell application "Numbers"
activate
make new document
tell document 1
tell sheet 1
tell table 1
tell row 1
set value of cell 1 to "Calendar Name"
set value of cell 2 to "URL"
end tell
repeat with i from 1 to count of calendarURLs
set calendarName to item 1 of item i of calendarURLs
set theURL to item 2 of item i of calendarURLs
if not (exists row (i + 1)) then
make new row
end if
tell row (i + 1)
set value of cell 1 to calendarName
set value of cell 2 to theURL
end tell
end repeat
end tell
end tell
end tell
end tell