Hello,
Here is a script I've just made to import via a short cut your window configurations. I'm pretty new to sf, so don't hesitate if you have any advices :)
// Open up Import Session Data
sf.ui.proTools.menuClick({ menuPath: ['File', 'Import', 'Session Data...'] });
// Direction of the Session
sf.keyboard.press({
keys: "cmd+shift+g",
});
sf.keyboard.type({
text: "/Volumes/romain 3To/OPJ 2019/Templates/Windows Configuration.ptx",
});
sf.wait({
intervalMs: 500,
});
sf.keyboard.press({
keys: "return",
});
sf.wait({
intervalMs: 500,
});
sf.keyboard.press({
keys: "return",
});
// Check the parameter Windows Configurations
var prefsWin = sf.ui.proTools.dialogWaitForManual({ dialogTitle: 'Import Session Data' }).dialog;
var SessionDataGroup = prefsWin.getFirstWithTitle("Session Data");
var WindowConfigurations = SessionDataGroup.getFirstWithTitle("Window Configurations");
WindowConfigurations.checkboxSet({
targetValue: 'Enable' //or 'Enable' or 'Disable'
});
prefsWin.getFirstWithTitle("OK").elementClick();
Linked from:
- Christian Scheuer @chrscheuer2019-12-04 21:34:31.185Z
Hi Romain :)
Almost there - you need the three backticks without the parentheses ;)
- LLe Bras Romain @Le_Bras_Romain
hahaha yes I've jusst figured it out editing the last script haha thanks you very much
- In reply tochrscheuer⬆:
Christian Scheuer @chrscheuer2019-12-04 21:41:01.996Z
I would do it like this:
function navigateToInDialog(win, path) { //Open the Go to... sheet sf.keyboard.type({ text: '/' }); //Wait for the sheet to appear var sheet = win.sheets.first.elementWaitFor({ timeout: 500 }, 'Could not find "Go to" sheet in the Save/Open dialog').element; //Set the value of the combo box sheet.comboBoxes.first.value.value = path; //Press OK sheet.buttons.whoseTitle.is('Go').first.elementClick({}, 'Could not click "Go"'); //Wait for sheet to close win.sheets.first.elementWaitFor({ waitForNoElement: true, timeout: 500 }, '"Go to" sheet didn\'t close in time'); } function importSession(sessionPath) { // Open up Import Session Data sf.ui.proTools.menuClick({ menuPath: ['File', 'Import', 'Session Data...'] }); // Wait for window to open var importWin = sf.ui.proTools.windows.whoseTitle.is('Open').first; // Navigate to folder navigateToInDialog(importWin, sessionPath); // Click Open importWin.buttons.whoseTitle.is('Open').first.elementClick(); // Wait for import window to close importWin.elementWaitFor({ waitForNoElement: true }); } function main() { //Import session importSession("/Volumes/romain 3To/OPJ 2019/Templates/Windows Configuration.ptx"); //Wait for Import Session Data var importSessionWin = sf.ui.proTools.windows.whoseTitle.is('Import Session Data').first.elementWaitFor().element; //Enable "Window Configurations" var sessionDataGroup = importSessionWin.getFirstWithTitle("Session Data"); var windowConfigurations = sessionDataGroup.getFirstWithTitle("Window Configurations"); windowConfigurations.checkboxSet({ targetValue: 'Enable' //or 'Enable' or 'Disable' }); //Click OK importSessionWin.getFirstWithTitle("OK").elementClick(); } main();
- VVanessa Garde @Vanessa_Garde
Trying this scripts but it's giving me an error on line 9:
any hints to get it resolved?
Thanks!
My line 9 is:
var sheet = win.sheets.first.elementWaitFor({ timeout: 500 }, 'Could not find "Go to" sheet in the Save/Open dialog').element;
Vanessa G.
- OOwen Granich-Young @Owen_Granich_Young
Hey Vanessa, this is all apple’s fault. :p
Every time they update the OS they change how the sheets look and work and Christian is stuck reworking the navigate to code. The latest version is in the protools main package but obviously that doesn’t roll back into the forum posts.
I've taken the liberty of using that most updated code in import scripts that you can download from the store in my ‘Automated Protools Imports’ package. Use the ‘Auto Import Template' for the more up to date version of this script. Or find it here Creating an "Import Mix Template" macro. #post-2 as just a script.
I've attached a quick video here on how to set up your own preset for 'Auto Import Template' in the package. I hope this helps!
https://www.dropbox.com/s/4fprhkek3lj2e0q/AUTO IMPORT PRESET.mov?dl=0Bests,
Owen- OOwen Granich-Young @Owen_Granich_Young
Oh and I just read the actual subject header lol. This is only for window configs... lol. Please ignore my post. I'll update the package to include that option at a later date, but here's the OG script with the new navigate to code see if it works for you.
// Navigate to File Function function navigateTo(path) { //Get a reference to the focused window in the frontmost app: var win = sf.ui.frontmostApp.focusedWindow; //Open the Go to... sheet sf.keyboard.type({ text: '/' }); //Wait for the sheet to appear var sheet = win.sheets.first.elementWaitFor({ timeout: 500 }, 'Could not find "Go to" sheet in the Save/Open dialog').element; //It's a combo box on older OS'es, from 12.something it's a text field if (sheet.comboBoxes.first.exists) { sheet.comboBoxes.first.value.value = path; //Press OK sheet.buttons.whoseTitle.is('Go').first.elementClick({}, 'Could not click "Go"'); } else { //Newer OS. //TextField with AXConfirm var textField = sheet.textFields.first; if (!textField.exists) throw `Can't find text field`; textField.value.value = path; sheet.elementRaise(); textField.mouseClickElement({ relativePosition: { x: 5, y: 5 }, }); sf.keyboard.press({ keys: 'return' }); } //Wait for sheet to close win.sheets.first.elementWaitFor({ waitForNoElement: true, timeout: 2500 }, '"Go to" sheet didn\'t close in time'); } /// Import Selected Function function importSession(selectedPath) { const numberOfTriesClickingOpen = 40; const timeToWaitBetweenOpenAttempts = 200; sf.ui.proTools.appActivateMainWindow(); // Open up Import Session Data sf.ui.proTools.menuClick({ menuPath: ['File', 'Import', 'Session Data...'] }); // Wait for window to open var importWin = sf.ui.proTools.windows.whoseTitle.is('Open').first; // Navigate to folder navigateTo(selectedPath); sf.wait({ intervalMs: 50, }); // Click Open //Press Open, try up to 10 times var openSuccess = false; for (var i = 0; i < numberOfTriesClickingOpen; i++) { try { if (importWin.invalidate().buttons.whoseTitle.is('Open').first.elementClick({ onError: 'Continue' }).success) { openSuccess = true; break; } } catch (err) { } sf.wait({ intervalMs: timeToWaitBetweenOpenAttempts }); } if (!openSuccess) throw "Could not click 'Open'"; // Wait for import window to close importWin.elementWaitFor({ waitForNoElement: true }); } function main() { //Import session importSession("/Volumes/romain 3To/OPJ 2019/Templates/Windows Configuration.ptx"); //Wait for Import Session Data var importSessionWin = sf.ui.proTools.windows.whoseTitle.is('Import Session Data').first.elementWaitFor().element; //Enable "Window Configurations" var sessionDataGroup = importSessionWin.getFirstWithTitle("Session Data"); var windowConfigurations = sessionDataGroup.getFirstWithTitle("Window Configurations"); windowConfigurations.checkboxSet({ targetValue: 'Enable' //or 'Enable' or 'Disable' }); //Click OK importSessionWin.getFirstWithTitle("OK").elementClick(); } main();
Untested see if that helps!
- VVanessa Garde @Vanessa_Garde
Thanks Owen for your message.
Unfortunately, it's giving the same error as before. PT 2012.12 and Big Sur, here.
Thanks for the advice.
- OOwen Granich-Young @Owen_Granich_Young
I'm sorry to hear that, I've updated my package in the store so users can toggle the check boxes in Session Data:
Give that a shot and let me know if it works.
Bests,
Owen- RRobert Acocella @Robert_Acocella
After trying both a scripted version above, and this Auto Import Template, I realize both are requiring an extra key input from me (Return), and I don't mind. But this macro kicks this error. Even despite the error, it does open the Session Data import window, and the correct boxes are all checked, only requiring me to click OK or press Return on my keyboard. Not complaining, just curious why it's doing that. I'm new to this and trying to dive into as much as I can for educational purposes.
- OOwen Granich-Young @Owen_Granich_Young
Yo boss, I have not updated this to the latest protools import window. It's been happening to me too lol, just been too busy working to fix it vs hitting the return button too lol.
- RRobert Acocella @Robert_Acocella
lol, totally not a complaint, so I hope you didn't take it as one. After reading this thread I noticed that this is one of those things that's subject to constant change because of OS and PT versions and I guess I was just looking for confirmation that it was that, and not something I was doing wrong. Hitting return isn't the worst thing I have to do every day!
- OOwen Granich-Young @Owen_Granich_Young
Didn't take it that way at all! All good! This package has been on my 'update to do' list. It's in need of a general overahaul.
- In reply toRobert_Acocella⬆:OOwen Granich-Young @Owen_Granich_Young
Yo I fixed this today, you can on your side pretty easy too, make an editable copy and go to line 110 it should read
const sessionDataCheckboxes = sf.ui.proTools.windows.whoseTitle.is("Import Session Data").first.groups.whoseTitle.is("Session Data").first
change it to
let sessionDataCheckboxes = sf.ui.proTools.windows.whoseTitle.is("Import Session Data").first.groups.whoseTitle.is("Main Playlist Options").first;
- RRobert Acocella @Robert_Acocella
I don't have a line 110, mine only goes to 98. Oh boy...
- OOwen Granich-Young @Owen_Granich_Young
Bhahah, I must be looking at the wrong package. I fixed the #0 thing in a different script lol.
- OOwen Granich-Young @Owen_Granich_Young
Out of curiousity @Kitch does this SDK work?
sf.app.proTools.importSessionData({ adjustSessionStartTimeToMatchSource : false, audioMediaOptions : "LinkToSourceAudio", executionMode : "Foreground", importClipGain : true, importClipsAndMedia : false, importVolumeAutomation : true, sessionPath : "/Volumes/OCD 2/SUPERVISOR_TEMPLATE.ptx", audioHandleSize : 0 })
So far if I don't include
audioHandleSize
it logs :audio_handle_size (PT_UnknownError) (SDK Auto Import: Line 1)
And if I do includeaudioHandleSize
it logsUnable to complete the command due to an unknown error. (PT_InvalidParameter) (SDK Auto Import: Line 1)
Basically Robert was seeing if we could shortcut this whole script and use the latest SDK to get this done, but I'm having trouble getting it to run.
- OOwen Granich-Young @Owen_Granich_Young
Holy Shit! That worked! Just filled out a lot more parameters.
@Robert_Acocella try this instead! You can change the things you need to, the most important one to change is
sessionPath :
your pathname here
sf.app.proTools.importSessionData({ adjustSessionStartTimeToMatchSource : false, audioMediaOptions : "LinkToSourceAudio", executionMode : "Background", importClipGain : true, importClipsAndMedia : false, importVolumeAutomation : true, sessionPath : "/Volumes/OCD 2/SUPERVISOR_TEMPLATE.ptx", audioHandleSize : 0, onError : "ThrowError", playlistOptions :"DoNotImport", timecodeMappingStartTime : `01:00:00:00`, timecodeMappingUnits :"MaintainAbsoluteTimeCodeValues", trackMatchOptions : "ImportAsNewTrack", videoMediaOptions : "LinkToSourceVideo" })
Excuse me while i rebuild all my session Import scripts :P
- RRobert Acocella @Robert_Acocella
I'm not sure this is what I need. I need it to import a Window Config from a session, nothing else. I don't see a line for Window Config and I have no idea how to script to even put it there.
- LIn reply toLe_Bras_Romain⬆:Le Bras Romain @Le_Bras_Romain
Thank you Christian,
First time for me that I have to deal with functions in SF. I will inform me.
I don't know what i'm doing wrong with your script but i'm stuck with this message and can 't go ahead :- LLe Bras Romain @Le_Bras_Romain
I ' ve found the solution. I have to replace all “Go“ and “Openr“ in the script by the french words “Aller“ et “Ouvrir“
Thanks a million for the script.Christian Scheuer @chrscheuer2019-12-05 02:59:02.353Z
Great you found out how to adapt it :)