-
Notifications
You must be signed in to change notification settings - Fork 0
/
Bounce Bunny beta36.applescript
310 lines (194 loc) · 8.49 KB
/
Bounce Bunny beta36.applescript
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"
property aStatusItem : missing value
on run
init() of me
end run
on menu_click(mList)
local appName, topMenu, r
2
-- Validate our input
if mList's length < 3 then error "Menu list is not long enough"
-- Set these variables for clarity and brevity later on
set {appName, topMenu} to (items 1 through 2 of mList)
set r to (items 3 through (mList's length) of mList)
-- This overly-long line calls the menu_recurse function with
-- two arguments: r, and a reference to the top-level menu
tell application "System Events" to my menu_click_recurse(r, ((process appName)'s (menu bar 1)'s (menu bar item topMenu)'s (menu topMenu)))
end menu_click
on menu_click_recurse(mList, parentObject)
local f, r
-- `f` = first item, `r` = rest of items
set f to item 1 of mList
if mList's length > 1 then set r to (items 2 through (mList's length) of mList)
-- either actually click the menu item, or recurse again
tell application "System Events"
if mList's length is 1 then
click parentObject's menu item f
else
my menu_click_recurse(r, (parentObject's (menu item f)'s (menu f)))
end if
end tell
end menu_click_recurse
on init()
set aList to {"Bounce", "Stop", "", "Quit"}
set aStatusItem to current application's NSStatusBar's systemStatusBar()'s statusItemWithLength:(current application's NSVariableStatusItemLength)
aStatusItem's setTitle:"Bounce Bunny"
aStatusItem's setHighlightMode:true
aStatusItem's setMenu:(createMenu(aList) of me)
end init
on createMenu(aList)
set aMenu to current application's NSMenu's alloc()'s init()
set aCount to 1
repeat with i in aList
set j to contents of i
if j is not equal to "" then
if j = "Quit" then
set aMenuItem to (current application's NSMenuItem's alloc()'s initWithTitle:j action:"actionHandler:" keyEquivalent:"")
--(aMenuItem's setKeyEquivalentModifierMask:(current application's NSControlKeyMask))
else
set aMenuItem to (current application's NSMenuItem's alloc()'s initWithTitle:j action:"actionHandler:" keyEquivalent:"")
end if
else
set aMenuItem to (current application's NSMenuItem's separatorItem())
end if
(aMenuItem's setTarget:me)
(aMenuItem's setTag:aCount)
(aMenu's addItem:aMenuItem)
if j is not equal to "" then
set aCount to aCount + 1
end if
end repeat
return aMenu
end createMenu
on actionHandler:sender
set aTitle to title of sender as string
if aTitle is equal to "Quit" then
current application's NSStatusBar's systemStatusBar()'s removeStatusItem:aStatusItem
if (name of current application) is not "Script Editor" then
tell current application to quit
end if
else if aTitle is equal to "Bounce" then
--set T1 to minutes of (current date)
--set T1s to seconds of (current date) --Set Start Time
delay 2
--set T2 to minutes of (current date)
--set T2s to seconds of (current date) --Set End Time
set BBv to "Bounce Bunny beta36"
tell application BBv to activate
set theResponse to display dialog "How many tracks to bounce ?" default answer "1" with icon note buttons {"Cancel", "Continue"} default button "Continue"
--> {button returned:"Continue", text returned:"Jen"}
display dialog "Total Tracks " & (text returned of theResponse) & "."
set theResponse to (text returned of theResponse)
tell application "Finder"
set currentPath to choose folder
end tell
tell application "Logic Pro X" to activate --Bring Logic in front
set firstB to theResponse
repeat while theResponse > 0
if firstB = theResponse then
menu_click({"Logic Pro X", "Logic Pro X", "Key Commands", "Presets", "BBKCv1"}) -- Key Commands
else
set TT_ to ((T2 * 60) + T2s) - ((T1 * 60) + T1s)
set ETB to ((TT_ * theResponse) / 60)
set ETB to (round (ETB * 100)) / 100
display notification "Remaining tracks " & theResponse & "." & " TPB " & TT_ & "sec" & "Estimated Time Remaing " & ETB & "mins"
--display notification "Estimated Time Remaing " & ETB
--Commands being here
end if
delay 0.2
set T1 to minutes of (current date)
set T1s to seconds of (current date) --Set Start Time
tell application "Logic Pro X" to activate --Bring Logic in front
delay 0.3
menu_click({"Logic Pro X", "Track", "Rename Track"}) -- Rename Track
delay 0.1
menu_click({"Logic Pro X", "Edit", "Copy"}) -- Copy Track Name
delay 0.1
tell application "System Events" to keystroke return --Deselect Track Name
delay 0.1
tell application "System Events" to keystroke "s" using {shift down} --Solo Selected Track
delay 0.1
tell application "System Events" to keystroke "b" using {command down} --Bounce Track
delay 0.3
if firstB = theResponse then
tell application BBv to activate
display dialog "Set The Settings You Want the Bounce Bunny To Bounce Your Tracks in Logic and Press Continue" buttons {"Cancel", "Continue"} default button "Continue"
delay 0.3
tell application "Logic Pro X" to activate --Bring Logic in front
delay 0.3
tell application "System Events" to keystroke return --initiate Bounce
delay 0.3
menu_click({"Logic Pro X", "Edit", "Paste"}) -- Paste Track Name
delay 1
tell application "System Events" to keystroke "g" using {command down, shift down} --go to folder
delay 0.5
tell application "System Events" to keystroke currentPath
delay 2.5
tell application "System Events" to keystroke return --select folder
delay 0.2
tell application "System Events" to keystroke return --Bounce
else
tell application "System Events" to keystroke return --Bounce
tell application "System Events" to keystroke "v" using {command down} --Paste Track Name
delay 1
tell application "System Events" to keystroke return --Bounce
end if
delay 1
delay 2
tell application "System Events"
--if (exists window "Logic Pro X" of application process "Logic Pro X") then
if firstB = theResponse then
repeat while (exists window "Logic Pro X" of application process "Logic Pro X")
delay 1
display dialog "Remaining tracks " & theResponse & "." buttons {"Stop", "Continue"} default button "Continue" cancel button "Stop" giving up after 5
--display notification GUT
delay 1
end repeat
else
repeat while (exists window "Logic Pro X" of application process "Logic Pro X")
delay 1
--set T2 to minutes of (current date)
--set T2s to seconds of (current date) --Set End Time
--set TT_ to ((T2 * 60) + T2s) - ((T1 * 60) + T1s)
display dialog "Tracks " & theResponse & "." & " TPB:" & TT_ & "sec. " & "Estimated Time Remaing " & ETB & "mins" buttons {"Stop", "Continue"} default button "Continue" cancel button "Stop" giving up after 3
--display notification GUT
delay 1
end repeat
end if
tell application "Logic Pro X" to activate --Bring Logic in front
tell application "System Events" to keystroke "s" using {shift down} --Unsolo Selected Track
tell application "System Events" to key code 125 --Unsolo Selected Track
--else
delay 3
--end if
end tell
set theResponse to theResponse - 1
set T2 to minutes of (current date)
set T2s to seconds of (current date) --Set End Time
end repeat
delay 1
tell application "Finder" to activate --Bring Finder in front
tell application "System Events" to keystroke "g" using {command down, shift down} --go to folder
delay 1
tell application "System Events" to keystroke return --Goto the Folder
-- # Your code to run for this menu choice goes here:
else if aTitle is equal to "Stop" then
set T1 to minutes of (current date)
set T1s to seconds of (current date)
say "stop................. wait a minute"
delay 10
set T2 to minutes of (current date)
set T2s to seconds of (current date)
set TT_ to ((T2 * 60) + T2s) - ((T1 * 60) + T1s)
display dialog "Timer Test Expect 12 sec " & TT_ & " sec"
--Its a New Day.
-- # Your code to run for this menu choice goes here:
--else if aTitle is equal to "Takaaki" then
-- # Your code to run for this menu choice goes here:
--else if aTitle is equal to "Naganoya" then
-- # Your code to run for this menu choice goes here:
end if
end actionHandler: