-
Notifications
You must be signed in to change notification settings - Fork 21
/
306 JavaScript For Automation [English].srt
4012 lines (3162 loc) · 74.8 KB
/
306 JavaScript For Automation [English].srt
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
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1
00:00:12,082 --> 00:00:14,401
well come welcome the Friday
2
00:00:15,139 --> 00:00:16,900
thanks for being here
3
00:00:16,009 --> 00:00:19,038
my name is south to go in I am the
product manager for automation
4
00:00:20,019 --> 00:00:22,081
technologies that Apple incorporated
5
00:00:22,081 --> 00:00:26,116
and the secession 306 this is a big day
6
00:00:27,016 --> 00:00:32,072
we get to welcome JavaScript to the
family of scripting languages on OS 10
7
00:00:32,072 --> 00:00:39,072
we've been waiting a long time for this
and I know our customers have to and
8
00:00:41,008 --> 00:00:42,012
we're really thrilled about it
9
00:00:42,048 --> 00:00:46,767
and before I get into the details have
the language and how it works
10
00:00:47,199 --> 00:00:50,294
I like to take a moment to reflect on
the state of automation
11
00:00:51,149 --> 00:00:54,190
beginning with Mavericks
12
00:00:54,019 --> 00:00:57,091
now in maverick's reintroduced
13
00:00:57,091 --> 00:01:00,168
a host of new features some very
powerful things beginning with
14
00:01:01,068 --> 00:01:02,075
notification support
15
00:01:03,038 --> 00:01:07,060
in both the scripting language in in
Automator as well so it became very
16
00:01:07,006 --> 00:01:11,099
easy to use notifications and set a
posting dialogues in your automation
17
00:01:12,053 --> 00:01:13,059
routines
18
00:01:13,059 --> 00:01:18,075
we also introduced code signing ability
in our editor applications both in
19
00:01:18,075 --> 00:01:19,161
Automator in the script editor
20
00:01:20,061 --> 00:01:23,160
which is great because then you could
sign and deliver
21
00:01:24,006 --> 00:01:28,009
automation solutions to your customers
friends and coworkers
22
00:01:28,063 --> 00:01:33,552
we also introduced a new construct in
AppleScript called the use statement
23
00:01:34,119 --> 00:01:38,140
the racks I can importer to import
functionality from
24
00:01:38,014 --> 00:01:42,097
applications and frameworks and %uh
scripting additions
25
00:01:42,097 --> 00:01:45,125
and allow them to be used in your
scripts
26
00:01:46,025 --> 00:01:50,106
and by doing this we also made it
possible to have script
27
00:01:51,006 --> 00:01:55,014
library that we introduced and script
library for scripts that you create
28
00:01:55,086 --> 00:01:55,185
yourself
29
00:01:56,085 --> 00:02:00,088
that contain your favorite some routines
are handlers
30
00:02:00,088 --> 00:02:04,717
and you can call in lo these libraries
from scripts anywhere in the operating
31
00:02:05,509 --> 00:02:06,210
system
32
00:02:06,021 --> 00:02:09,114
they can also take advantage of
AppleScript objective-c
33
00:02:10,014 --> 00:02:13,040
and any the cocoa calls that you want to
use
34
00:02:13,004 --> 00:02:17,005
so they're very powerful very useful
they be introduced
35
00:02:17,005 --> 00:02:20,334
and then finally we had a new feature
36
00:02:20,829 --> 00:02:24,885
that worked on english-only systems but
we thought it was so interesting that we
37
00:02:25,389 --> 00:02:28,820
introduced it it was called speaker
bulwark locks
38
00:02:28,082 --> 00:02:31,561
and allowed you to take your Automator
workflow
39
00:02:32,299 --> 00:02:35,650
and save it as a speaker bull item
40
00:02:35,065 --> 00:02:39,066
in the dictation architecture so you
could say a command in would run your
41
00:02:39,075 --> 00:02:39,744
workflow
42
00:02:40,419 --> 00:02:44,590
and so maverick's is a very productive
release force we're very excited about
43
00:02:44,059 --> 00:02:44,488
it
44
00:02:45,019 --> 00:02:50,047
but we're also excited about what we've
done in Yosemite and how it builds upon
45
00:02:50,299 --> 00:02:51,970
the groundwork relayed
46
00:02:51,097 --> 00:02:54,103
in Mavericks last part of this
47
00:02:55,003 --> 00:02:58,022
evolutionary process we integrated
48
00:02:58,022 --> 00:03:02,109
code signing with workflow files so not
only app lets but now your workflow
49
00:03:03,009 --> 00:03:05,188
files can be code side as well
50
00:03:05,269 --> 00:03:10,160
and because have changes that we
implemented in the app script language
51
00:03:10,016 --> 00:03:11,017
for supporting
52
00:03:11,026 --> 00:03:14,185
optional parameters and subroutines and
handlers
53
00:03:14,419 --> 00:03:20,620
wearin able to upgrade the scripting
library support so that you can now have
54
00:03:20,062 --> 00:03:21,271
your favorite calls
55
00:03:21,829 --> 00:03:26,680
have optional premonition users as well
very good improvement there
56
00:03:26,068 --> 00:03:30,079
and listening to customer requests
they're being
57
00:03:30,079 --> 00:03:34,868
for years and years requesting some way
to indicate a progress
58
00:03:35,579 --> 00:03:39,584
method for their automation routines we
now have
59
00:03:40,079 --> 00:03:43,220
built in script progress indicators
60
00:03:43,022 --> 00:03:46,079
so by calling simple properties
61
00:03:46,079 --> 00:03:50,088
you can have your scripts display a
progress
62
00:03:50,088 --> 00:03:53,197
indicator as a circle or even as
63
00:03:53,989 --> 00:03:58,993
a progress bar in a floating window and
all this is done for you automatically
64
00:03:59,389 --> 00:04:02,880
all you have to do is Sep properties
within your scripts
65
00:04:02,088 --> 00:04:06,627
so I think our customers are gonna
really enjoy that particular feature
66
00:04:07,419 --> 00:04:12,450
and we took the idea of spiegel were
close and we've advanced it now
67
00:04:12,729 --> 00:04:17,060
because %uh the new dictation
architecture in Yosemite that works with
68
00:04:17,006 --> 00:04:17,495
all
69
00:04:17,549 --> 00:04:21,060
languages we now have a new template
item
70
00:04:21,006 --> 00:04:24,115
in Automator for creating a dictation
71
00:04:24,169 --> 00:04:29,630
command so you create your workflow you
save it it's a than to the dictation
72
00:04:29,063 --> 00:04:30,071
architecture
73
00:04:30,071 --> 00:04:34,096
and when you're in the process of
dictating or just sitting at the machine
74
00:04:34,096 --> 00:04:37,177
you can't say the name your command
anymore execute
75
00:04:38,077 --> 00:04:42,078
very interesting very powerful I know
you can have a lot of fun exploring
76
00:04:42,078 --> 00:04:46,143
that so that's just a quick overview up
where we've been
77
00:04:47,043 --> 00:04:51,182
but something that's been on our minds
for a long time that we're happy
78
00:04:51,569 --> 00:04:57,050
and very pleased to have here today is
JavaScript for automation
79
00:04:57,005 --> 00:05:00,008
now those have you there are
80
00:05:00,008 --> 00:05:04,317
premiere with JavaScript from the
web-based community
81
00:05:04,389 --> 00:05:07,650
this is not the JavaScript for writing a
DOM
82
00:05:07,065 --> 00:05:10,161
that uses CSS and HTML 5 to create a web
app
83
00:05:11,061 --> 00:05:15,270
we're talking about extending the
JavaScript cord language
84
00:05:15,819 --> 00:05:18,838
to integrate with the open scripting
architecture
85
00:05:19,009 --> 00:05:23,250
and by doing this you now gain the
ability to pull
86
00:05:23,025 --> 00:05:27,033
all those levers inside the scriptable
caps on your operating system
87
00:05:28,005 --> 00:05:32,524
to perform the kinda repetitive for
interesting or complex tasks
88
00:05:32,569 --> 00:05:37,330
that you do every day and now this power
it's available to you
89
00:05:37,033 --> 00:05:40,062
through JavaScript now many of you that
right
90
00:05:40,062 --> 00:05:43,981
JavaScript professionally or as your
focus
91
00:05:44,539 --> 00:05:47,870
you use to using editors like God BB
added
92
00:05:47,087 --> 00:05:50,108
sublime tax were web storm
93
00:05:51,008 --> 00:05:54,127
TextMate things like that up
94
00:05:54,199 --> 00:05:58,870
initially as you adapt to JavaScript raw
to Mason
95
00:05:58,087 --> 00:06:02,386
you write your for scripts in the script
editor application
96
00:06:03,169 --> 00:06:06,500
and I'm gonna give you just a short
overview up
97
00:06:06,005 --> 00:06:09,354
this application it's interfacing
preferences
98
00:06:09,849 --> 00:06:13,800
so that you understand what's happening
as David presents
99
00:06:13,008 --> 00:06:16,367
JavaScript for you so let me take a look
at
100
00:06:17,159 --> 00:06:21,060
the script editor application so when
you open
101
00:06:21,006 --> 00:06:26,071
the script editor application get this
very simple interface is a script window
102
00:06:26,071 --> 00:06:29,810
and he has a simple but very powerful
design to it
103
00:06:30,449 --> 00:06:34,477
beginning with the little slider that
separates the two main pains up the
104
00:06:34,729 --> 00:06:35,560
window
105
00:06:35,056 --> 00:06:39,058
the script pain where you enter the code
for your script
106
00:06:39,058 --> 00:06:42,099
and the bottom pane contains in a vet
law
107
00:06:42,099 --> 00:06:46,588
so ass the script is executing you'll
see the events listed there with the
108
00:06:47,479 --> 00:06:49,520
results coming in from the Abetz
109
00:06:49,889 --> 00:06:53,973
and this is all I've logged happens as
the script is executed
110
00:06:54,729 --> 00:06:59,530
at the top there are some simple
controls for basically compiling the
111
00:06:59,053 --> 00:07:02,022
script to make sure your syntax is
correct
112
00:07:02,499 --> 00:07:06,560
and there's also control for running or
stopping your script
113
00:07:06,056 --> 00:07:10,143
now there at the bottom here is a
language controls so make sure if you're
114
00:07:11,043 --> 00:07:12,552
writing JavaScript
115
00:07:12,939 --> 00:07:18,941
that this pop-up menu is set for the
JavaScript language
116
00:07:19,139 --> 00:07:24,176
and that's basically the interface in
the way that it works is
117
00:07:24,509 --> 00:07:27,518
you enter your script code
118
00:07:27,599 --> 00:07:33,662
into the top area then you click the Run
button
119
00:07:34,229 --> 00:07:38,251
an acid execute you can see that there's
a progress indicator here on the right
120
00:07:38,449 --> 00:07:43,464
showing the progress at the script and
you can watch the event log go by
121
00:07:43,599 --> 00:07:48,608
now this simple script that exported
open keno documents to movies
122
00:07:48,689 --> 00:07:52,620
you can see the results of it and how
was logged in everything indicated in
123
00:07:52,062 --> 00:07:54,541
the final result that the script at the
bottom
124
00:07:55,099 --> 00:07:59,134
so this is the interface that you have
when you're executing scripts in is
125
00:07:59,449 --> 00:08:00,080
David
126
00:08:00,008 --> 00:08:04,157
shows you the examples this is what
you're going to see
127
00:08:04,229 --> 00:08:07,245
there's some other important preferences
you should be aware of and let me just
128
00:08:07,389 --> 00:08:09,860
quickly show you those to you
129
00:08:09,086 --> 00:08:12,785
so in the Preferences menu
130
00:08:13,559 --> 00:08:17,626
from the application menu in the General
Settings paying
131
00:08:18,229 --> 00:08:22,312
there is a default language pop-up if
you going to be using javascript is your
132
00:08:23,059 --> 00:08:25,085
primary language for scripting
133
00:08:25,319 --> 00:08:28,331
you wanna make sure that you change this
value
134
00:08:28,439 --> 00:08:32,120
to JavaScript now this is JavaScript 100
135
00:08:32,012 --> 00:08:35,871
this is JavaScript for automation 10 it
is not
136
00:08:35,979 --> 00:08:41,330
JavaScript what now we use the current
JavaScript court languages the bases
137
00:08:41,033 --> 00:08:44,037
so don't be freaked out when you see 10
their
138
00:08:44,073 --> 00:08:47,100
also make sure that you check
139
00:08:48,000 --> 00:08:51,339
the show's script menu and menu bar
option
140
00:08:51,339 --> 00:08:55,540
and what this will do is activate the
system wide script menu at the top right
141
00:08:55,054 --> 00:08:56,403
up your menu bar
142
00:08:56,889 --> 00:09:01,190
and from this script menu you can host
your favorite scripts
143
00:09:01,019 --> 00:09:05,023
and you can make them available
contextually within certain applications
144
00:09:05,023 --> 00:09:07,037
so if you write scripts for the Finder
145
00:09:07,037 --> 00:09:10,105
they can only appear the finders there
are few write scripts four pages
146
00:09:11,005 --> 00:09:14,030
the only pier 1 pages so there it's up
to you
147
00:09:14,003 --> 00:09:17,072
the script menu run shell scripts
AppleScript applications workflows
148
00:09:17,099 --> 00:09:19,100
JavaScript
149
00:09:20,000 --> 00:09:23,339
any kind scripting language supported by
the operating system
150
00:09:23,339 --> 00:09:27,310
can run from the script min so you'll be
taking advantage of that
151
00:09:27,031 --> 00:09:32,116
in addition if you want to set certain
coloring for you the code that you use
152
00:09:33,016 --> 00:09:37,021
this formatting pain is where you'll do
that you can choose fonts font size and
153
00:09:37,066 --> 00:09:37,795
coloring
154
00:09:38,389 --> 00:09:43,300
to apply to fit comfortably with what
your use too
155
00:09:43,003 --> 00:09:46,592
next I like to look at dictionaries
156
00:09:46,889 --> 00:09:49,952
now in the operating system every
scriptable
157
00:09:50,519 --> 00:09:53,582
application carries internally within
its bundle
158
00:09:54,149 --> 00:09:58,670
a complete dictionary of all the term
said it understands
159
00:09:58,067 --> 00:10:02,079
it will list all the class sense at all
the methods in the commands in the
160
00:10:02,079 --> 00:10:04,068
properties and elements
161
00:10:04,779 --> 00:10:09,820
that is for mayor with so this is where
you will go to learn about how to
162
00:10:09,082 --> 00:10:11,163
control a particular application
163
00:10:12,063 --> 00:10:15,122
and what you do is you choose Open
dictionary from the File menu
164
00:10:16,022 --> 00:10:19,381
and in the forthcoming dialog choose an
application
165
00:10:19,579 --> 00:10:23,623
when you do that York see a script
viewer window like this one for the
166
00:10:24,019 --> 00:10:24,800
keynote
167
00:10:24,008 --> 00:10:27,014
dictionary and this is
168
00:10:27,086 --> 00:10:31,150
what you see when you I'll look at an
application scripting dictionary and
169
00:10:32,005 --> 00:10:36,154
this is what you will do to navigate
that dictionary
170
00:10:36,649 --> 00:10:41,500
at the top is a language button so this
dictionary fewer functions
171
00:10:41,005 --> 00:10:44,016
for all the scripting languages we
support so
172
00:10:44,061 --> 00:10:47,790
it supports JavaScript AppleScript or
objective c-
173
00:10:48,339 --> 00:10:51,375
and you can change the mode for viewing
the content
174
00:10:51,699 --> 00:10:54,790
right from this menu now
175
00:10:54,079 --> 00:10:59,048
at the top part love this window the top
pain in this window is the model viewer
176
00:10:59,759 --> 00:11:01,811
in this is where you see how the objects
177
00:11:02,279 --> 00:11:06,730
in the application scripting model are
reflected
178
00:11:06,073 --> 00:11:10,135
on the left hand side typically a
scripting dictionary
179
00:11:11,035 --> 00:11:16,066
is grouped into sweets and the suites
are usually grouped by functionality you
180
00:11:16,066 --> 00:11:17,110
buy what they do
181
00:11:18,001 --> 00:11:22,050
in this particular example you'll see
that there's multiple sweet
182
00:11:22,149 --> 00:11:26,157
their suites for I work because keynote
is part of the I work family affair
183
00:11:26,949 --> 00:11:28,550
plications
184
00:11:28,055 --> 00:11:32,092
the I work sweets upcoming objects in
common commands
185
00:11:32,092 --> 00:11:35,881
are included there and then keynote has
its own sweet
186
00:11:36,709 --> 00:11:40,721
are things that are particular for the
keynote application
187
00:11:40,829 --> 00:11:45,380
and then once a sweet is selected you'll
see in the next column
188
00:11:45,038 --> 00:11:50,987
the methods and the classes that belong
to that particular sweet so here we have
189
00:11:51,329 --> 00:11:57,050
commands like export we would export a
project presentation EC classes like
190
00:11:57,005 --> 00:11:58,032
document
191
00:11:58,032 --> 00:12:01,101
and then when you select the class
you'll see he
192
00:12:01,389 --> 00:12:04,670
elements X that belong to that class
193
00:12:04,067 --> 00:12:07,149
in the right hand column and also the
properties
194
00:12:08,049 --> 00:12:11,085
I love that particular class in here you
see the properties
195
00:12:11,085 --> 00:12:14,086
I love a keynote document
196
00:12:14,086 --> 00:12:17,565
now for further information in detail
about these
197
00:12:18,339 --> 00:12:21,420
in the bottom half for the Windows the
dictionary viewer
198
00:12:22,149 --> 00:12:26,500
and the dictionary viewer contains the
definitions for all those particular
199
00:12:26,005 --> 00:12:27,018
elements
200
00:12:27,063 --> 00:12:30,069
so when you want to know about why
hideaway script the Finder hideaway
201
00:12:31,023 --> 00:12:32,492
script numbers
202
00:12:32,699 --> 00:12:36,380
how do I skip keynote how do I script
aperture
203
00:12:36,038 --> 00:12:39,131
you open a dictionary and this is where
you learn and explore
204
00:12:40,031 --> 00:12:43,550
to find out how to control those
applications
205
00:12:43,829 --> 00:12:49,050
so that's the scripting dictionary and
that's the script editor application
206
00:12:49,005 --> 00:12:53,794
so let me get out of the way and bring
up David sign bird
207
00:12:53,839 --> 00:12:56,895
whose the newest member of our team to
show you
208
00:12:57,399 --> 00:13:02,240
JavaScript rodham Asian enjoy this
209
00:13:02,024 --> 00:13:05,085
thank you sell hello everyone thank you
for being here
210
00:13:05,085 --> 00:13:09,087
I it's a great honor I'm really excited
to be showing this awesome new feature
211
00:13:09,087 --> 00:13:13,106
OS 10 yosemite JavaScript for automation
212
00:13:14,006 --> 00:13:17,093
so today's talk will cover what
JavaScript for automation is
213