Hi,
I recently updated my laptop system to Catalina from Mojave, and since then, several of my most used export audio scripts are failing. I'm sure it's an OS related issue, but I'm hoping someone might be able to help me resolve it as I've tried a few things, and I'm stumped.
The scripts all include an Export Selection element, and since Catalina, it can't seem to navigate the Destination Directory to the right location.
The error message is as follows: Could not find "Go To" sheet in the Save/Open dialog (Rename and Export Mix WAV - to MIXES: Line 121) Element was not found or removed after waiting 500ms
The script itself is below, and any ideas are gratefully welcomed!
Cheers,
Tim
sf.ui.proTools.appActivateMainWindow();
sf.ui.proTools.groupsEnsureGroupListIsVisible();
function getGroupListItem(name) {
var groupList = sf.ui.proTools.mainWindow.tables.whoseTitle.contains('Group').first;
return groupList.childrenByRole("AXRow").allItems.map(function (r) {
return {
row: r,
selectBtn: r.childrenByRole("AXCell").first.children.first,
name: r.childrenByRole("AXCell").allItems[1].children.first.title.value.match(/^.+ - ([^(]+)/)[1].replace(/ $/, ''),
};
}).filter(function (r) { return r.name == name })[0];
}
var groupListItem = getGroupListItem("Mix PRINT");
groupListItem.selectBtn.elementClick();
//Get selected track Name
let trackName = (sf.ui.proTools.selectedTrackNames[0] + " MAIN");
//Open Rename window
sf.ui.proTools.menuClick({ menuPath: ['Clip', 'Rename...'] });
//Reference for Rename Window
const win = sf.ui.proTools.windows.whoseTitle.is('Name');
//Wait for rename Window
win.first.elementWaitFor();
//Set the clip name to Track name
win.first.groups.first.textFields.first.elementSetTextFieldWithAreaValue({
value: trackName,
});
sf.keyboard.press({
keys: "cmd+a, cmd+c",
});
sf.ui.proTools.windows.whoseTitle.is('Name').first.buttons.whoseTitle.is('OK').first.elementClick();
sf.ui.proTools.windows.whoseTitle.is('Name').first.elementWaitFor({
waitType: "Disappear",
});
sf.ui.proTools.menuClick({
menuPath: ["View","Other Displays","Clip List"],
targetValue: "Enable",
});
sf.ui.proTools.mainWindow.children.whoseRole.is("AXStaticText").whoseValue.is('CLIPS').first.elementWaitFor();
////Get Sample Rate/////
function getSessionSampleRate() {
if (!sf.ui.proTools.windows.whoseTitle.is('Session Setup').first.exists) {
sf.ui.proTools.menuClick({
menuPath: ["Setup", "Session"],
});
}
const win = sf.ui.proTools.windows.whoseTitle.is('Session Setup').first;
const sessionFormatPanel = win.groups.whoseTitle.is('Session Format').first;
const sampleRateString = sessionFormatPanel.children.whoseRole.is("AXStaticText").allItems[2].value.invalidate().value;
sf.ui.proTools.menuClick({
menuPath: ["Setup", "Session"],
});
const sessionSampleRate = Number(sampleRateString.split(' ')[0]) + ' kHz';
return sessionSampleRate;
}
const sessionSampleRate = getSessionSampleRate();
/* log(sampleRate); */
//////////////
sf.ui.proTools.mainWindow.popupButtons.whoseTitle.is('Clip List').first.popupMenuSelect({
menuPath: ["Export Clips as Files..."],
});
var exportDlg = sf.ui.proTools.dialogWaitForManual({
dialogTitle: "Export Selected"
}).dialog;
//Get the Children of the Export Selected dialog, filter them so we only get the popupbuttons,
var popupButtons = exportDlg.getElements("AXChildren").filter(function (e) { return e.fullRole == "AXPopUpButton" });
//Assign thefourthree buttons coming out of the previous instruction to individual variables
var sampleRate = popupButtons[0];
var bitDepth = popupButtons[1];
var fileFormat = popupButtons[2];
var fileTypeBtn = popupButtons[3];
//Change any options that aren't right
if (fileTypeBtn.value.value != 'WAV')
fileTypeBtn.popupMenuSelect({ menuPath: ['WAV'] });
if (fileFormat.value.value != 'Interleaved')
fileFormat.popupMenuSelect({ menuPath: ['Interleaved'] });
if (bitDepth.value.value != '32 Bit Float')
bitDepth.popupMenuSelect({ menuPath: ['32 Bit Float'] });
if (sampleRate.value.value != sessionSampleRate)
sampleRate.popupMenuSelect({ menuPath: [sessionSampleRate] });
//--------------------------------
// Set the export directory to the refs folder - I probably didn't need to copy these and rename them but I haven't gone back to see if anything changed so better safe than sorry
//--------------------------------
function navigateToInDialog2(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 openDialogFolder2(folder) {
var openDlg = sf.ui.proTools.windows.whoseTitle.is('Open').first;
navigateToInDialog2(openDlg, folder);
//Click OK
openDlg.buttons.whoseTitle.is('Open').first.elementClick();
//Wait for the Open dialog to close
openDlg.elementWaitFor({ waitForNoElement: true });
};
// Set a variable to the desired refs directory in the sessions parent folder
var exportDirectory = sf.ui.proTools.mainWindow.sessionPath.split('/').slice(0, -1).join('/') + "/Mixes";
//Make sure our desired export dir exists
sf.system.exec({ commandLine: 'mkdir -p "' + exportDirectory + '"' });
//Get the current export directory - I'm sure this can all be done one line but, well, newbie
var existingDirectory = sf.ui.proTools.windows.whoseTitle.is('Export Selected').first.children.whoseRole.is("AXStaticText").allItems[5].value.value;
var modifiedDirectory = "/"+ existingDirectory.substring(0, existingDirectory.length - 1).split(":").slice (1).join('/');
if (modifiedDirectory !== exportDirectory) {
sf.ui.proTools.windows.whoseTitle.is('Export Selected').first.buttons.whoseTitle.is('Choose...').first.elementClick();
openDialogFolder2(exportDirectory);
}
// Start the Export
sf.ui.proTools.windows.whoseTitle.is('Export Selected').first.buttons.whoseTitle.is('Export...').first.elementClick();
sf.ui.proTools.windows.whoseTitle.is('Export Selected').first.elementWaitFor({
waitType: "Disappear",
});
- Christian Scheuer @chrscheuer2021-08-03 14:58:56.748Z
Hi TJ,
When it reports the error, does the sheet actually appear visually (like here)?
- TTJ Allen @TJ_Allen
Hi Christian,
No, it doesn't appear. I can get it to appear if I manually hit '/', but the script no longer opens the sheet.
Cheers,
Tim
- In reply toTJ_Allen⬆:Chris Shaw @Chris_Shaw2021-08-03 16:20:40.320Z
Perhaps replacing
sf.keyboard.type({ text: '/' })
withsf.keyboard.press({keys:'/'})
?You may want to put a
sf.wait ({intervalMs:15})
before and after it for timing purposes since keypresses can be unpredictable. - In reply toTJ_Allen⬆:Raphael Sepulveda @raphaelsepulveda2021-08-03 17:00:51.143Z
I'd try adding this:
sf.ui.proTools.windows.whoseTitle.is("Open").first.elementWaitFor();
...right after this line (line 157):
sf.ui.proTools.windows.whoseTitle.is('Export Selected').first.buttons.whoseTitle.is('Choose...').first.elementClick();
So that it waits for the window to open before trying to open the sheet.
Christian Scheuer @chrscheuer2021-08-03 17:52:54.829Z
^ This ^
Or, even, just add this in the
openDialogFolder2
function right before the call tonavigateToInDialog2
:openDlg.elementWaitFor();
- TTJ Allen @TJ_Allen
Thanks so much everyone for your help! Adding the
openDlg.elementWaitFor();
seems to have done the trick. I'll add it in to the bigger scripts and test them now.