Created
January 31, 2016 23:33
-
-
Save stephenhandley/55835a510f46fa694551 to your computer and use it in GitHub Desktop.
Failed attempt at getting ableton to export a project via js automation on mac
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env osascript -l JavaScript | |
function run(argv) { | |
var folder = argv[0]; | |
console.log(folder); | |
var fm = $.NSFileManager.defaultManager; | |
var contents = fm.contentsOfDirectoryAtPathError(folder, null); | |
var alsFile = ObjC.unwrap(contents).map(function (oItem) { | |
return ObjC.unwrap(oItem); | |
}).filter(function (file) { | |
console.log(file); | |
return file.match(/\.als$/); | |
})[0]; | |
if (!alsFile) { | |
console.log('No Live project file found'); | |
return; | |
} | |
alsFile = folder + alsFile; | |
console.log(alsFile); | |
var app = Application.currentApplication(); | |
app.includeStandardAdditions = true; | |
app.doShellScript('open "' + alsFile + '"'); | |
// ??? Can't get this stuff to work | |
delay(0.5); | |
var se = Application('System Events'); | |
// Press Cmd-Shift-R (export) | |
se.keystroke('R', { using: ['shift down', 'command down']}); | |
// Press Enter | |
se.keyCode(36); | |
se.keyCode(36); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment