JavaScript for Automation -...
Transcript of JavaScript for Automation -...
![Page 1: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/1.jpg)
© 2014 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple.
#WWDC14
JavaScript for Automation
Session 306 Sal Soghoian Product Manger Automation Technologies
Services
![Page 2: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/2.jpg)
![Page 3: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/3.jpg)
Automation in Mavericks
Notifications
Code signing
use statements
Script libraries
Speakable workflows
![Page 4: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/4.jpg)
Automation in Yosemite
Code-signed workflows
Enhanced script libraries
Script progress indicators
Dictation commands
![Page 5: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/5.jpg)
JavaScript for Automation
![Page 6: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/6.jpg)
Script Editor
![Page 7: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/7.jpg)
![Page 8: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/8.jpg)
Slider
![Page 9: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/9.jpg)
Script
Slider
![Page 10: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/10.jpg)
Script
Event Log
Slider
![Page 11: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/11.jpg)
![Page 12: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/12.jpg)
Compile
![Page 13: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/13.jpg)
Run
![Page 14: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/14.jpg)
Stop
![Page 15: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/15.jpg)
Language
![Page 16: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/16.jpg)
![Page 17: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/17.jpg)
AppleScript
![Page 18: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/18.jpg)
JavaScript
![Page 19: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/19.jpg)
Language
![Page 20: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/20.jpg)
![Page 21: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/21.jpg)
Keynote = Application('Keynote')
documents = Keynote.documents
progress = $.NSProgress.currentProgressprogress.totalUnitCount = documents.length
destinationPath = $('~/Movies').stringByExpandingTildeInPath
for (i in documents) {document = documents[i]exportName = document.name().replace('.key','.m4v')document.export({
to: Path(destinationPath.js + '/' + exportName),as: 'QuickTime movie'
})progress.completedUnitCount = i
}
progress.completedUnitCount = documents.length
Script
![Page 22: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/22.jpg)
Keynote = Application('Keynote')
documents = Keynote.documents
progress = $.NSProgress.currentProgressprogress.totalUnitCount = documents.length
destinationPath = $('~/Movies').stringByExpandingTildeInPath
for (i in documents) {document = documents[i]exportName = document.name().replace('.key','.m4v')document.export({
to: Path(destinationPath.js + '/' + exportName),as: 'QuickTime movie'
})progress.completedUnitCount = i
}
progress.completedUnitCount = documents.length
// Target app "Keynote"! Application("Keynote").documents.length! ! --> 3! /* Progress: 1 of 3 */! Application("Keynote").documents[0].name()! ! --> “New Product Design.key"! Application("Keynote").export([object ObjectSpecifier], {to:[object ObjectSpecifier], as:'QuickTime movie’})! /* Progress: 33% completed */
Event Log
Script
Progress Indicator
![Page 23: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/23.jpg)
Keynote = Application('Keynote') !documents = Keynote.documents !progress = $.NSProgress.currentProgress progress.totalUnitCount = documents.length !destinationPath = $('~/Movies').stringByExpandingTildeInPath !for (i in documents) { document = documents[i] exportName = document.name().replace('.key','.m4v') document.export({ to: Path(destinationPath.js + '/' + exportName), as: 'QuickTime movie' }) progress.completedUnitCount = i } !progress.completedUnitCount = documents.length!
Event Log
Script
Progress Indicator
![Page 24: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/24.jpg)
Keynote = Application('Keynote') !documents = Keynote.documents !progress = $.NSProgress.currentProgress progress.totalUnitCount = documents.length !destinationPath = $('~/Movies').stringByExpandingTildeInPath !for (i in documents) { document = documents[i] exportName = document.name().replace('.key','.m4v') document.export({ to: Path(destinationPath.js + '/' + exportName), as: 'QuickTime movie' }) progress.completedUnitCount = i } !progress.completedUnitCount = documents.length!
! Application("Keynote").documents[1].name()! ! --> “Wind Power.key”! /* Progress: 2 of 3 */! Application("Keynote").export([object ObjectSpecifier], {to:[object ObjectSpecifier], as:'QuickTime movie'})! /* Progress: 66% completed */
Event Log
Script
Progress Indicator
![Page 25: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/25.jpg)
Keynote = Application('Keynote') !documents = Keynote.documents !progress = $.NSProgress.currentProgress progress.totalUnitCount = documents.length !destinationPath = $('~/Movies').stringByExpandingTildeInPath !for (i in documents) { document = documents[i] exportName = document.name().replace('.key','.m4v') document.export({ to: Path(destinationPath.js + '/' + exportName), as: 'QuickTime movie' }) progress.completedUnitCount = i } !progress.completedUnitCount = documents.length!
Event Log
Script
Progress Indicator
![Page 26: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/26.jpg)
Keynote = Application('Keynote') !documents = Keynote.documents !progress = $.NSProgress.currentProgress progress.totalUnitCount = documents.length !destinationPath = $('~/Movies').stringByExpandingTildeInPath !for (i in documents) { document = documents[i] exportName = document.name().replace('.key','.m4v') document.export({ to: Path(destinationPath.js + '/' + exportName), as: 'QuickTime movie' }) progress.completedUnitCount = i } !progress.completedUnitCount = documents.length!
! Application("Keynote").documents[2].name()! ! --> "Community Projects.key"! Application("Keynote").export([object ObjectSpecifier], {to:[object ObjectSpecifier], as:'QuickTime movie'})! /* Progress: 3 of 3 */! /* Progress: 100% completed */// Stop targetingResult:3
Event Log
Script
![Page 27: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/27.jpg)
![Page 28: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/28.jpg)
![Page 29: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/29.jpg)
![Page 30: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/30.jpg)
General Settings
![Page 31: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/31.jpg)
Default Language
![Page 32: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/32.jpg)
AppleScript
![Page 33: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/33.jpg)
JavaScript
![Page 34: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/34.jpg)
![Page 35: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/35.jpg)
Script Menu
![Page 36: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/36.jpg)
Script Menu
Script Menu
![Page 37: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/37.jpg)
Formatting
![Page 38: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/38.jpg)
Formatting
![Page 39: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/39.jpg)
![Page 40: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/40.jpg)
![Page 41: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/41.jpg)
![Page 42: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/42.jpg)
Language
![Page 43: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/43.jpg)
Language
![Page 44: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/44.jpg)
LanguageAppleScript
![Page 45: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/45.jpg)
LanguageAppleScript
JavaScript
![Page 46: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/46.jpg)
LanguageAppleScript
JavaScriptObjective-C
![Page 47: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/47.jpg)
![Page 48: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/48.jpg)
Model Viewer
![Page 49: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/49.jpg)
Suite
![Page 50: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/50.jpg)
Suite
Methods
![Page 51: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/51.jpg)
Suite
Class
Methods
![Page 52: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/52.jpg)
Suite
Class
ElementsMethods
![Page 53: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/53.jpg)
Suite
Class
Properties
ElementsMethods
![Page 54: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/54.jpg)
Definition Viewer
![Page 55: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/55.jpg)
Class
Properties
Elements
Methods
![Page 56: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/56.jpg)
![Page 57: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/57.jpg)
Script Editor
![Page 58: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/58.jpg)
JavaScript for Automation
David Steinberg Automation Engineer
![Page 59: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/59.jpg)
JavaScript for Automation
Application scripting
Libraries and applets
UI scripting
Using system APIs
![Page 60: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/60.jpg)
Automation
![Page 61: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/61.jpg)
AutomationAutomate tasks
![Page 62: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/62.jpg)
AutomationAutomate tasks
![Page 63: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/63.jpg)
AutomationInteract with applications
![Page 64: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/64.jpg)
+ + +
AutomationInteract with applications
![Page 65: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/65.jpg)
Demo
![Page 66: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/66.jpg)
Automation
![Page 67: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/67.jpg)
Cocoa Scripting
Automation
![Page 68: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/68.jpg)
Cocoa Scripting
!
!
!
!
Object Model
!
!
!
!
Object Model
Automation
!
!
!
!
Object Model
![Page 69: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/69.jpg)
Cocoa Scripting
!
!
!
!
Object Model
!
!
!
!
Object Model
!
!
!
!
Object Model
Automation
![Page 70: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/70.jpg)
Apple EventsCocoa Scripting
!
!
!
!
Object Model
!
!
!
!
Object Model
!
!
!
!
Object Model
Automation
![Page 71: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/71.jpg)
Apple EventsCocoa Scripting
!
!
!
!
Object Model
!
!
!
!
Object Model
!
!
!
!
Object Model
Automation
![Page 72: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/72.jpg)
Apple Events
AppleScript Objective-C
Python
Ruby
Perl
Cocoa Scripting
!
!
!
!
Object Model
!
!
!
!
Object Model
!
!
!
!
Object Model
Automation
![Page 73: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/73.jpg)
AutomationObject model
![Page 74: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/74.jpg)
AutomationObject model
![Page 75: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/75.jpg)
application
application "Mail"
AutomationObject model
![Page 76: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/76.jpg)
application
inbox
application "Mail"inbox of
AutomationObject model
![Page 77: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/77.jpg)
application
inbox
messages
application "Mail"inbox of
AutomationObject model
![Page 78: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/78.jpg)
application
inbox
messages
message 1 message 2. . .
application "Mail"inbox ofmessage 2 of
AutomationObject model
![Page 79: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/79.jpg)
JavaScript
![Page 80: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/80.jpg)
JavaScript and Automation
![Page 81: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/81.jpg)
JavaScript and Automation
Cocoa Scripting
!
!
!
!
Object Model
!
!
!
!
Object Model
!
!
!
!
Object Model
Apple Events
![Page 82: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/82.jpg)
JavaScript and Automation
Cocoa Scripting
!
!
!
!
Object Model
!
!
!
!
Object Model
!
!
!
!
Object Model
Apple EventsJavaScript
CoreJavaScript AE Bridge
![Page 83: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/83.jpg)
Application Scripting
![Page 84: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/84.jpg)
Application ScriptingApplication object
![Page 85: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/85.jpg)
Name: Application('Safari')
Application ScriptingApplication object
![Page 86: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/86.jpg)
Name: Application('Safari')
Bundle ID: Application('com.apple.mail')
Application ScriptingApplication object
![Page 87: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/87.jpg)
Name: Application('Safari')
Bundle ID: Application('com.apple.mail')
Path: Application('/Applications/TextEdit.app')
Application ScriptingApplication object
![Page 88: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/88.jpg)
Name: Application('Safari')
Bundle ID: Application('com.apple.mail')
Path: Application('/Applications/TextEdit.app')
Process ID: Application(763)
Application ScriptingApplication object
![Page 89: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/89.jpg)
Name: Application('Safari')
Bundle ID: Application('com.apple.mail')
Path: Application('/Applications/TextEdit.app')
Process ID: Application(763)
Current Application: Application.currentApplication()
Application ScriptingApplication object
![Page 90: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/90.jpg)
Application ScriptingSyntax
![Page 91: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/91.jpg)
Application ScriptingSyntax
Properties: Safari.name
![Page 92: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/92.jpg)
Application ScriptingSyntax
Properties: Safari.name
Elements: Safari.documents[0]
![Page 93: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/93.jpg)
Application ScriptingSyntax
Properties: Safari.name
Elements: Safari.documents[0]
Commands: Safari.open(...)
![Page 94: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/94.jpg)
Application ScriptingSyntax
Properties: Safari.name
Elements: Safari.documents[0]
Commands: Safari.open(...)
Classes: Safari.Document(...)
![Page 95: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/95.jpg)
Application ScriptingGetting and setting properties
![Page 96: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/96.jpg)
Application ScriptingGetting and setting properties
Safari = Application(‘Safari')
![Page 97: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/97.jpg)
Application ScriptingGetting and setting properties
Safari = Application(‘Safari')
doc = Safari.document[0]
![Page 98: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/98.jpg)
Application ScriptingGetting and setting properties
Safari = Application(‘Safari')
doc = Safari.document[0]
url = doc.url()
![Page 99: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/99.jpg)
Application ScriptingGetting and setting properties
Safari = Application(‘Safari')
doc = Safari.document[0]
url = doc.url()
doc.url = 'http://apple.com'
![Page 100: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/100.jpg)
Application ScriptingElement arrays
![Page 101: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/101.jpg)
Application ScriptingElement arrays
Safari = Application('Safari')
![Page 102: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/102.jpg)
Application ScriptingElement arrays
Safari = Application('Safari')
window = Safari.windows[0]
![Page 103: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/103.jpg)
Application ScriptingElement arrays
Safari = Application('Safari')
window = Safari.windows[0]
window = Safari.windows['Apple']
![Page 104: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/104.jpg)
Application ScriptingElement arrays
Safari = Application('Safari')
window = Safari.windows[0]
window = Safari.windows['Apple']
window = Safari.windows['#412']
![Page 105: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/105.jpg)
Demo
![Page 106: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/106.jpg)
Application ScriptingFiltering arrays
![Page 107: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/107.jpg)
Mail = Application(‘Mail')
Application ScriptingFiltering arrays
![Page 108: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/108.jpg)
Mail = Application(‘Mail')
jsEmails = Mail.inbox.messages.whose({subject:'JavaScript'})
Application ScriptingFiltering arrays
![Page 109: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/109.jpg)
Application ScriptingSending commands
![Page 110: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/110.jpg)
Mail = Application('Mail')
Application ScriptingSending commands
![Page 111: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/111.jpg)
Mail = Application('Mail')
message = Mail.inbox.messages[0]
Application ScriptingSending commands
![Page 112: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/112.jpg)
Mail = Application('Mail')
message = Mail.inbox.messages[0]
message.open()
Application ScriptingSending commands
![Page 113: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/113.jpg)
Mail = Application('Mail')
message = Mail.inbox.messages[0]
message.open()
Mail.open(message)
Application ScriptingSending commands
![Page 114: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/114.jpg)
Mail = Application('Mail')
message = Mail.inbox.messages[0]
message.open()
Mail.open(message)
Application ScriptingSending commands
response = message.reply({ replyAll: true, openingWindow: false })
![Page 115: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/115.jpg)
Application ScriptingPaths
![Page 116: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/116.jpg)
TextEdit = Application('TextEdit')
Application ScriptingPaths
![Page 117: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/117.jpg)
TextEdit = Application('TextEdit')
path = Path(‘/Users/username/Desktop/foo.rtf')
Application ScriptingPaths
![Page 118: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/118.jpg)
TextEdit = Application('TextEdit')
path = Path(‘/Users/username/Desktop/foo.rtf')
TextEdit.open(path)
Application ScriptingPaths
![Page 119: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/119.jpg)
Application ScriptingCreating objects
![Page 120: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/120.jpg)
TextEdit = Application(‘TextEdit')
Application ScriptingCreating objects
![Page 121: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/121.jpg)
TextEdit = Application(‘TextEdit')
doc = TextEdit.Document()
Application ScriptingCreating objects
![Page 122: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/122.jpg)
TextEdit = Application(‘TextEdit')
doc = TextEdit.Document()
TextEdit.documents.push(doc)
Application ScriptingCreating objects
![Page 123: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/123.jpg)
TextEdit = Application(‘TextEdit')
doc = TextEdit.Document()
TextEdit.documents.push(doc)
doc.text = 'Hello world’
Application ScriptingCreating objects
![Page 124: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/124.jpg)
TextEdit = Application(‘TextEdit')
doc = TextEdit.Document()
TextEdit.documents.push(doc)
doc.text = 'Hello world’
jsDoc = TextEdit.Document({text:'JavaScript for Automation'})
Application ScriptingCreating objects
TextEdit.documents.push(jsDoc)
![Page 125: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/125.jpg)
Application ScriptingStandard additions
![Page 126: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/126.jpg)
app = Application.currentApplication()
Application ScriptingStandard additions
![Page 127: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/127.jpg)
app = Application.currentApplication()
app.includeStandardAdditions = true
Application ScriptingStandard additions
![Page 128: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/128.jpg)
app = Application.currentApplication()
app.includeStandardAdditions = true
app.beep(3)
Application ScriptingStandard additions
![Page 129: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/129.jpg)
app = Application.currentApplication()
app.includeStandardAdditions = true
app.beep(3)
app.say('Hello world')
Application ScriptingStandard additions
![Page 130: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/130.jpg)
app = Application.currentApplication()
app.includeStandardAdditions = true
app.beep(3)
app.say('Hello world')
app.displayAlert('Finished task')
Application ScriptingStandard additions
![Page 131: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/131.jpg)
Libraries
![Page 132: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/132.jpg)
function log(message,format) { ... }
Libraries
Home Library Script Libraries toolbox.scpt
![Page 133: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/133.jpg)
function log(message,format) { ... }
Libraries
Home Library Script Libraries toolbox.scpt
toolbox = Library('toolbox') !
toolbox.log('hello world')
![Page 134: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/134.jpg)
Applets
![Page 135: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/135.jpg)
AppletsEvent handlers
![Page 136: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/136.jpg)
AppletsEvent handlers
function run() { ... }
![Page 137: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/137.jpg)
AppletsEvent handlers
function run() { ... }
function openDocuments(docs) { ... }
![Page 138: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/138.jpg)
AppletsEvent handlers
function run() { ... }
function openDocuments(docs) { ... }
function printDocuments(docs) { ... }
![Page 139: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/139.jpg)
AppletsEvent handlers
function run() { ... }
function openDocuments(docs) { ... }
function printDocuments(docs) { ... }
function idle() { ... }
![Page 140: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/140.jpg)
AppletsEvent handlers
function run() { ... }
function openDocuments(docs) { ... }
function printDocuments(docs) { ... }
function idle() { ... }
function reopen() { ... }
![Page 141: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/141.jpg)
AppletsEvent handlers
function run() { ... }
function openDocuments(docs) { ... }
function printDocuments(docs) { ... }
function idle() { ... }
function reopen() { ... }
function quit() { ... }
![Page 142: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/142.jpg)
Demo
![Page 143: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/143.jpg)
UI Scripting
![Page 144: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/144.jpg)
UI ScriptingBuilt on accessibility
![Page 145: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/145.jpg)
UI ScriptingBuilt on accessibility
![Page 146: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/146.jpg)
UI ScriptingBuilt on accessibility
System Events
![Page 147: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/147.jpg)
UI ScriptingBuilt on accessibility
System Events
UI Scripting
![Page 148: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/148.jpg)
UI ScriptingClicking and typing
![Page 149: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/149.jpg)
UI ScriptingClicking and typing
SystemEvents = Application('System Events’)
![Page 150: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/150.jpg)
UI ScriptingClicking and typing
SystemEvents = Application('System Events’)
notesUI = SystemEvents.processes[‘Notes']
![Page 151: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/151.jpg)
UI ScriptingClicking and typing
SystemEvents = Application('System Events’)
notesUI = SystemEvents.processes[‘Notes']
notesUI.windows[0].buttons[0].click()
![Page 152: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/152.jpg)
UI ScriptingClicking and typing
SystemEvents = Application('System Events’)
notesUI = SystemEvents.processes[‘Notes']
notesUI.windows[0].buttons[0].click()
Notes = Application('Notes') Notes.activate()
![Page 153: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/153.jpg)
UI ScriptingClicking and typing
SystemEvents = Application('System Events’)
notesUI = SystemEvents.processes[‘Notes']
notesUI.windows[0].buttons[0].click()
Notes = Application('Notes') Notes.activate()
SystemEvents.keystroke('m', { using: 'command down' })
![Page 154: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/154.jpg)
Using System APIs
![Page 155: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/155.jpg)
Using System APIsObjC and $
![Page 156: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/156.jpg)
Using System APIsObjC and $
ObjC.wrap(...)
![Page 157: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/157.jpg)
Using System APIsObjC and $
ObjC.wrap(...)
ObjC.unwrap(...) ObjC.deepUnwrap(...)
![Page 158: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/158.jpg)
Using System APIsObjC and $
ObjC.wrap(...)
ObjC.unwrap(...) ObjC.deepUnwrap(...)
ObjC.import(...)
![Page 159: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/159.jpg)
Using System APIsObjC and $
ObjC.wrap(...)
ObjC.unwrap(...) ObjC.deepUnwrap(...)
ObjC.import(...)
$.NSString
![Page 160: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/160.jpg)
Using System APIsObjC and $
ObjC.wrap(...)
ObjC.unwrap(...) ObjC.deepUnwrap(...)
ObjC.import(...)
$.NSString
$('foo')
![Page 161: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/161.jpg)
Calling methodsUsing System APIs
![Page 162: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/162.jpg)
Calling methods
str = [[NSString alloc] initWithUTF8String:”bar”]; !
[str writeToFile:@"/tmp/foo" atomically:YES];
Using System APIs
![Page 163: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/163.jpg)
Calling methods
str = [[NSString alloc] initWithUTF8String:”bar”]; !
[str writeToFile:@"/tmp/foo" atomically:YES];
Using System APIs
str = $.NSString.alloc.initWithUTF8String(‘bar') !
str.writeToFileAtomically('/tmp/foo', true)
![Page 164: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/164.jpg)
Demo
![Page 165: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/165.jpg)
Accessing propertiesUsing System APIs
![Page 166: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/166.jpg)
Accessing properties
task = $.NSTask.alloc.init
Using System APIs
![Page 167: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/167.jpg)
Accessing properties
task = $.NSTask.alloc.init
task.running
Using System APIs
![Page 168: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/168.jpg)
Accessing properties
task = $.NSTask.alloc.init
task.running
task.launchPath = '/bin/sleep'
Using System APIs
![Page 169: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/169.jpg)
Bridged nilUsing System APIs
![Page 170: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/170.jpg)
Bridged nil
error = $()
Using System APIs
![Page 171: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/171.jpg)
Bridged nil
error = $()
Using System APIs
doc = $.NSXMLDocument.alloc.initWithXMLStringOptionsError( xmlString, undefined, error )
![Page 172: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/172.jpg)
Bridged nil
error = $()
Using System APIs
if (doc.isNil()) { $.NSLog(error.userInfo.description) }
doc = $.NSXMLDocument.alloc.initWithXMLStringOptionsError( xmlString, undefined, error )
![Page 173: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/173.jpg)
SubclassingUsing System APIs
![Page 174: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/174.jpg)
Subclassing
ObjC.registerSubclass({
Using System APIs
})
![Page 175: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/175.jpg)
Subclassing
ObjC.registerSubclass({ name: ‘AppDelegate',
Using System APIs
})
![Page 176: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/176.jpg)
Subclassing
ObjC.registerSubclass({ name: ‘AppDelegate', superclass: ‘NSObject’,
Using System APIs
})
![Page 177: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/177.jpg)
Subclassing
ObjC.registerSubclass({ name: ‘AppDelegate', superclass: ‘NSObject’, protocols: [‘NSApplicationDelegate'],
Using System APIs
})
![Page 178: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/178.jpg)
Subclassing
ObjC.registerSubclass({ name: ‘AppDelegate', superclass: ‘NSObject’, protocols: [‘NSApplicationDelegate'],
Using System APIs
properties: { window: 'id' },
})
![Page 179: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/179.jpg)
Subclassing
ObjC.registerSubclass({ name: ‘AppDelegate', superclass: ‘NSObject’, protocols: [‘NSApplicationDelegate'],
Using System APIs
properties: { window: 'id' }, methods: { 'applicationDidFinishLaunching:': { types: ['void', ['id']], implementation: function (notification) { $.NSLog('Application finished launching'); } } } })
![Page 180: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/180.jpg)
Demo
![Page 181: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/181.jpg)
Release notesUsing System APIs
![Page 182: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/182.jpg)
Release notes
Binding C functions
Using System APIs
![Page 183: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/183.jpg)
Release notes
Binding C functions
Explicit pass-by-reference
Using System APIs
![Page 184: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/184.jpg)
Release notes
Binding C functions
Explicit pass-by-reference
Passing functions as blocks
Using System APIs
![Page 185: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/185.jpg)
Where to Use It
![Page 186: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/186.jpg)
JavaScript for AutomationSystem-wide scripting
![Page 187: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/187.jpg)
Script Editor
JavaScript for AutomationSystem-wide scripting
![Page 188: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/188.jpg)
Script Editor
Applets/Droplets
JavaScript for AutomationSystem-wide scripting
![Page 189: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/189.jpg)
Script Editor
Applets/Droplets
Script Menu
JavaScript for AutomationSystem-wide scripting
![Page 190: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/190.jpg)
Script Editor Automator
Applets/Droplets
Script Menu
JavaScript for AutomationSystem-wide scripting
![Page 191: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/191.jpg)
Script Editor Automator
Applets/Droplets
Script Menu
JavaScript for AutomationSystem-wide scripting
Services
![Page 192: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/192.jpg)
Script Editor Automator
Applets/Droplets
Script Menu
JavaScript for AutomationSystem-wide scripting
osascript
Services
![Page 193: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/193.jpg)
Demo
![Page 194: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/194.jpg)
JavaScript for AutomationSummary
![Page 195: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/195.jpg)
JavaScript for AutomationSummary
Built on JavaScriptCore and OSA
![Page 196: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/196.jpg)
JavaScript for AutomationSummary
Built on JavaScriptCore and OSA
Integrated system-wide
![Page 197: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/197.jpg)
JavaScript for AutomationSummary
Built on JavaScriptCore and OSA
Integrated system-wide
Offers many options for scripting
![Page 198: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/198.jpg)
JavaScript for AutomationCall to action
![Page 199: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/199.jpg)
JavaScript for AutomationCall to action
Script applications
![Page 200: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/200.jpg)
JavaScript for AutomationCall to action
Script applications
Make your applications scriptable
![Page 201: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/201.jpg)
JavaScript for AutomationCall to action
Script applications
Make your applications scriptable
Tell others to make their applications scriptable
![Page 202: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/202.jpg)
More Information
!
Documentation JavaScript for Automation Release Notes https://developer.apple.com
Apple Developer Forums http://devforums.apple.com
![Page 203: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/203.jpg)
Lab
• Automation Lab Services Lab B Friday 12:45PM
![Page 204: JavaScript for Automation - devstreaming.apple.comdevstreaming.apple.com/videos/.../306_javascript_for_automation.pdf · Automation in Yosemite Code-signed workflows Enhanced script](https://reader036.fdocuments.us/reader036/viewer/2022062311/5b8e4f3609d3f2a0138d4e8d/html5/thumbnails/204.jpg)