Skip to content

Instantly share code, notes, and snippets.

@stephenhandley
Created January 31, 2016 23:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stephenhandley/55835a510f46fa694551 to your computer and use it in GitHub Desktop.
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
#!/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