-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuickMusic2.applescript
More file actions
468 lines (431 loc) · 13.6 KB
/
Copy pathQuickMusic2.applescript
File metadata and controls
468 lines (431 loc) · 13.6 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
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
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
-- QuickMusic2.applescript
-- QuickMusic2
-- Created by Jake Wells on 9/21/10.
-- Copyright 2010 GlxyWell. All rights reserved.
on clicked theObject
set appname to contents of text field "app1" of window "newwindow"
tell application appname
activate
end tell
if name of theObject is "exit" then
quit
else if name of theObject is "uberbutton" then
set i to contents of control "therating" of window "newwindow"
tell application "iTunes"
set newrate to (i * 20)
set rating of current track to newrate
end tell
else if name of theObject is "artsearch" then
using terms from application "iTunes"
tell application "iTunes"
if exists (database ID of current track) then
set cur_artist to the artist of the current track
else
set cur_artist to ""
end if
end tell
end using terms from
set x to cur_artist
set contents of text field "thesearch" of window "newwindow" to x
if state of button "sandp" of window "newwindow" is 0 then
tell application "System Events"
keystroke tab
end tell
else
set state of button "sandp" of window "newwindow" to 0
tell application "System Events"
keystroke tab
end tell
delay 2
set state of button "sandp" of window "newwindow" to 1
end if
else if name of theObject is "playbtn" then
tell application "iTunes"
playpause
end tell
else if name of theObject is "prevbtn" then
tell application "iTunes"
previous track
end tell
else if name of theObject is "nextbtn" then
tell application "iTunes"
next track
end tell
else if name of theObject is "ami" then
tell application "System Events"
set fapp to the name of the first process whose frontmost is true
end tell
else if name of theObject is "rate" then
if state of theObject is 1 then
set visible of text field "titletext" of window "newwindow" to false
else
set visible of text field "titletext" of window "newwindow" to true
end if
else if name of theObject is "testing" then
if state of button "testing" of window "newwindow" is 0 then
tell application "Finder"
set {disp_x1, disp_y1, disp_x2, disp_y2} to bounds of window of desktop
end tell
repeat with theX from 95 to 330 by 6
set bounds of window "newwindow" to {disp_x2 - theX, disp_y2 - 44, disp_x2 - 0, disp_y2 - 20}
end repeat
else
tell application "Finder"
set {disp_x1, disp_y1, disp_x2, disp_y2} to bounds of window of desktop
end tell
repeat with theX from 330 to 95 by -6
set bounds of window "newwindow" to {disp_x2 - theX, disp_y2 - 44, disp_x2 - 0, disp_y2 - 20}
end repeat
end if
end if
end clicked
on mouse exited theObject event theEvent
if name of theObject is "titletext" then
using terms from application "iTunes"
tell application "iTunes"
if exists (database ID of current track) then
set cur_song to the name of the current track
set cur_artist to the artist of the current track
else
set cur_song to "No song info available"
set cur_artist to "Unknown"
end if
end tell
end using terms from
tell window "newwindow"
set the contents of text field "titleText" to cur_song
end tell
else if name of theObject is "rec1" then
set levwasVar to contents of text field "levwas" of window "newwindow"
set contents of the control "therating" of window "newwindow" to levwasVar
else if name of theObject is "rate" then
if state of theObject is 0 then
set visible of text field "titletext" of (window of theObject) to true
end if
end if
end mouse exited
on mouse entered theObject event theEvent
if name of theObject is "titletext" then
using terms from application "iTunes"
tell application "iTunes"
if exists (database ID of current track) then
set cur_song to the name of the current track
set cur_artist to the artist of the current track
else
set cur_song to "No song info available"
set cur_artist to "Unknown"
end if
end tell
end using terms from
tell window "newwindow"
set the contents of text field "titleText" to cur_artist
end tell
else if name of theObject is "sq0" then
set contents of the control "therating" of window "newwindow" to 0
else if name of theObject is "sq1" then
set contents of the control "therating" of window "newwindow" to 1
else if name of theObject is "sq2" then
set contents of the control "therating" of window "newwindow" to 2
else if name of theObject is "sq3" then
set contents of the control "therating" of window "newwindow" to 3
else if name of theObject is "sq4" then
set contents of the control "therating" of window "newwindow" to 4
else if name of theObject is "sq5" then
set contents of the control "therating" of window "newwindow" to 5
else if name of theObject is "playbtn" then
beep
else if name of theObject is "nextbtn" then
beep
else if name of theObject is "rate" then
if state of theObject is 0 then
set visible of text field "titletext" of (window of theObject) to false
end if
else if name of theObject is "prevbtn" then
beep
else if name of theObject is "exit" then
beep
else
delay 1
using terms from application "iTunes"
tell application "iTunes"
if exists (database ID of current track) then
set cur_song to the name of the current track
set cur_artist to the artist of the current track
else
set cur_song to "No song info available"
set cur_artist to "Unknown"
end if
end tell
end using terms from
tell window "newwindow"
set the contents of text field "titleText" to cur_song
end tell
end if
end mouse entered
on end editing theObject
set query to contents of text field "thesearch" of window "newwindow"
tell application "System Events"
if exists process "iTunes" then
set bob to visible of process "iTunes"
end if
end tell
tell application "iTunes"
set fred to minimized of front browser window
set col to collapsed of window "iTunes"
set vis to visible of window "iTunes"
end tell
tell application "iTunes"
activate
end tell
tell application "System Events"
tell application "iTunes"
activate
play
end tell
keystroke "l" using command down
keystroke tab
keystroke tab
keystroke "a"
keystroke (ASCII character 8)
keystroke query
keystroke tab
keystroke "£" using command down
end tell
if content of text field "viewref" of window "newwindow" is "0" then
tell application "System Events"
keystroke "3" using {command down, option down}
end tell
else if content of text field "viewref" of window "newwindow" is "1" then
tell application "System Events"
keystroke "4" using {command down, option down}
end tell
else if content of text field "viewref" of window "newwindow" is "2" then
tell application "System Events"
keystroke "5" using {command down, option down}
end tell
end if
if state of button "sandp" of window "newwindow" is 1 then
tell application "System Events"
tell application "iTunes"
stop
end tell
keystroke "a" using command down
keystroke space
tell application "System Events"
if exists process "iTunes" then
set visible of process "iTunes" to bob
end if
end tell
tell application "iTunes"
set visible of window "iTunes" to vis
set minimized of front browser window to fred
set collapsed of window "iTunes" to col
end tell
end tell
end if
using terms from application "iTunes"
tell application "iTunes"
if exists (database ID of current track) then
set cur_song to the name of the current track
set cur_artist to the artist of the current track
else
set cur_song to "No song info available"
set cur_artist to "Unknown"
end if
end tell
end using terms from
tell window "newwindow"
set the contents of text field "titleText" to cur_song
end tell
end end editing
on mouse down theObject
if name of theObject is "theslider" then
if content of text field "muter" of window "newwindow" is "t" then
set y to content of text field "volset" of window "newwindow"
set contents of slider "theslider" of window "newwindow" to y
set content of text field "muter" of window "newwindow" to "f"
tell application "iTunes"
set the sound volume to y
end tell
else if content of text field "muter" of window "newwindow" is "tp" then
set content of text field "muter" of window "newwindow" to "f"
set y to content of text field "volset" of window "newwindow"
set content of text field "muter" of window "newwindow" to "f"
tell application "iTunes"
set x to sound volume
set z to y
set a to 1
play
end tell
repeat z times
set sound volume to (a)
set a to a + 1
set contents of slider "theslider" of window "newwindow" to (a - 1)
end repeat
end if
end if
end mouse down
on action theslider
using terms from application "iTunes"
tell application "iTunes"
if exists (database ID of current track) then
set cur_song to the name of the current track
set cur_artist to the artist of the current track
else
set cur_song to "No song info available"
set cur_artist to "Unknown"
end if
end tell
end using terms from
tell window "newwindow"
set the contents of text field "titleText" to cur_song
end tell
set y to contents of slider "theslider" of window "newwindow" as integer
if content of text field "muter" of window "newwindow" is "tp" then
tell application "iTunes"
set x to sound volume
set z to (x - y)
if z is less than 0 then set z to (z * -1)
set a to 0
repeat z + 1 times
set sound volume to (x - a)
if x is greater than y then
set a to a + 1
else if y is greater than x then
set a to a - 1
else
set sound volume to x
exit repeat
end if
end repeat
play
end tell
else if y is 0 then
tell application "iTunes"
set x to the sound volume
end tell
set content of text field "volset" of window "newwindow" to x
set content of text field "muter" of window "newwindow" to "t"
tell application "iTunes"
if (player state is playing) then
set newrandvar to 1
end if
end tell
if newrandvar is 1 then set content of text field "muter" of window "newwindow" to "tp"
tell application "iTunes"
set x to sound volume
set z to (x - y)
if z is less than 0 then set z to (z * -1)
set a to 0
repeat z + 1 times
set sound volume to (x - a)
if x is greater than y then
set a to a + 1
else if y is greater than x then
set a to a - 1
else
set sound volume to x
exit repeat
end if
end repeat
pause
end tell
else
tell application "iTunes"
set the sound volume to y
end tell
end if
end action
on will close win
quit
end will close
on launched theapp
set prevsong to ""
set escape to "f"
tell application "Finder"
set {disp_x1, disp_y1, disp_x2, disp_y2} to bounds of window of desktop
end tell
set bounds of window "newwindow" to {disp_x2 - 330, disp_y2 - 44, disp_x2 - 0, disp_y2 - 20}
tell application "iTunes"
if exists (database ID of current track) then
set cur_song to the name of the current track
set cur_rate to the rating of the current track
else
set cur_song to "No song info available"
set cur_artist to "Unknown"
set cur_rate to 0
end if
end tell
tell window "newwindow"
set the contents of text field "titleText" to cur_song
set the contents of control "therating" to cur_rate / 20
set contents of text field "levwas" to cur_rate / 20
end tell
end launched
on activated theapp
set escape to "f"
tell application "iTunes"
set x to the sound volume
end tell
set contents of slider "theslider" of window "newwindow" to x
repeat while escape is "f"
set prevsong to contents of text field "prevsong" of window "newwindow"
tell application "iTunes"
if exists (database ID of current track) then
set cur_song to the name of the current track
set cur_song to the name of the current track
set cur_artist to the artist of the current track
set cur_rate to the rating of the current track
else
set cur_song to "No song info available"
set cur_artist to "Unknown"
set cur_rate to 0
end if
end tell
if (cur_song is not equal to prevsong) then
tell window "newwindow"
set the contents of text field "titleText" to cur_song
set the contents of the control "therating" to cur_rate / 20
set contents of text field "levwas" to cur_rate / 20
end tell
if content of text field "toggler" of window "newwindow" is "0" then
tell window "newwindow"
delay 1.5
set the contents of text field "titleText" to cur_artist
end tell
delay 2
set content of text field "toggler" of window "newwindow" to "0"
set state of button "testing" of window "newwindow" to 0
else
tell window "newwindow"
delay 1.5
set the contents of text field "titleText" to cur_artist
end tell
end if
set contents of text field "prevsong" of window "newwindow" to cur_song
else
tell window "newwindow"
set the contents of the control "therating" to cur_rate / 20
set contents of text field "levwas" to cur_rate / 20
set the contents of text field "titleText" to cur_song
delay 2
set the contents of text field "titleText" to cur_artist
end tell
end if
end repeat
end activated
on mouse up theObject event theEvent
set i to contents of control "therating" of window "newwindow"
tell application "iTunes"
set newrate to (i * 20)
set rating of current track to newrate
end tell
end mouse up
on should zoom theObject proposed bounds proposedBounds
end should zoom
on will become active theObject
tell application "System Events"
set fapp to the name of the first process whose frontmost is true
end tell
set the contents of text field "app1" of window "newwindow" to fapp
end will become active