I have a feeling this covered elsewhere but I can't seem to find all the pieces of the puzzle.
To automate dialog settings you need to set popup menus and checkboxes. I'll use the Commit Track dialog as an example. To automate the popup menus is easy and elegant. I read the popup buttons into an array and the assign variables to each menu. Then I can check the current value and change it if necessary.
var popupButtons = commitDlg.getElements("AXChildren").filter(function (e) { return e.fullRole == "AXPopUpButton" });
//Assign the two menus coming out of the previous instruction to individual variables
var commitType = popupButtons[0];
var postAction = popupButtons[1];
if (commitType.value.value != 'Selected Tracks')
commitType.popupMenuSelect({ menuPath: ['Selected Tracks'] });
if (postAction.value.value != 'Do Nothing')
postAction.popupMenuSelect({ menuPath: ['Do Nothing'] });
I can get the checkboxes into an array the same way (at least I don't get an error) using this code:
var checkBoxes = commitDlg.getElements("AXChildren").filter(function (e) { return e.fullRole == "AXCheckbox" });
var consClips = checkBoxes[0];
var renderVol = checkBoxes[1];
var renderPan = checkBoxes[2];
var copySends = checkBoxes[3];
var copyGroups = checkBoxes[4];
var insertAfter = checkBoxes[5];
var offline = checkBoxes[6];
But then I have to use this (which doesn't make use of the variables):
sf.ui.proTools.windows.whoseTitle.is('Commit Tracks').first.checkBoxes.allItems[0].checkboxSet({
targetValue: "Enable",
});
Instead of :
consClips.checkboxSet({
targetValue: "enable",
});
This gives an error, and if I try
consClips.first.checkboxSet()
I get a syntax error.
Can checkboxes not be put into variables this way?
Kitch Membery @Kitch2020-03-25 20:16:02.449Z2020-03-25 20:48:38.664ZI think I get what you are asking @Andrew_Scheps,
Applying somthing like this may work for the activation of each checkbox.
sf.ui.proTools.appActivateMainWindow(); var checkBoxes = [ { Title: 'Consolidate Clips', State: "Enable" }, { Title: 'Volume and Mute', State: "Enable" }, { Title: 'Sends', State: "Enable" }, { Title: 'Group Assignments', State: "Enable" }, { Title: 'Insert after last selected track', State: "Enable" }, { Title: 'Offline', State: "Enable" }, ]; checkBoxes.forEach(setCheckboxState); function setCheckboxState(item) { let commitTracksToInsertWindow = sf.ui.proTools.windows.whoseTitle.is('Commit Tracks to Insert').first; commitTracksToInsertWindow.checkBoxes.whoseTitle.is(item.Title).first.checkboxSet({ targetValue: (item.State), }); }Does that answer your question?
Kitch Membery @Kitch2020-03-25 20:38:43.448ZMy method doesn’t take into account the checkbox state grabbed by the array, but it will override them.
Andrew Scheps @Andrew_SchepsWhich is probably fine. Probable take just as long to check the state as to set it. Thanks!
- In reply toAndrew_Scheps⬆:
Christian Scheuer @chrscheuer2020-03-26 01:49:38.661ZIf you use actions with a "targetValue" property it means we check the existing value for you - so this code is as fast as you can do it.
- In reply toKitch⬆:
Dustin Harris @Dustin_Harris@Kitch I just learned about .forEach() and it's so elegant. I tried to adapt the above to a script I'm writing but I get a kAXillegalArgument error in line 25 (this line)
editWindowViewOptions.checkBoxes.whoseTitle.is(item.Title).first.checkboxSet({ targetValue: (item.State), });And the whole script is:
sf.ui.proTools.appActivateMainWindow(); const checkBoxes = [ { Title: 'Comments', State: "Enable" }, { Title: 'Mic Preamps', State: "Enable" }, { Title: 'Instrument', State: "Enable" }, { Title: 'Inserts A-E', State: "Enable" }, { Title: 'Inserts F-J', State: "Enable" }, { Title: 'Sends A-E', State: "Enable" }, { Title: 'Sends F-J', State: "Enable" }, { Title: 'I/O', State: "Enable" }, { Title: 'Object', State: "Enable" }, { Title: 'Real-Time Properties', State: "Enable" }, { Title: 'Track Color', State: "Enable" }, ]; checkBoxes.forEach(setCheckboxState); function setCheckboxState(item) { let editWindowViewOptions = sf.ui.proTools.mainWindow.buttons.whoseTitle.is('Edit Window View selector').first; editWindowViewOptions.checkBoxes.whoseTitle.is(item.Title).first.checkboxSet({ targetValue: (item.State), }); }Anything obviously egregious?
Cheers!
Kitch Membery @Kitch2020-06-05 02:32:06.506ZYeah Dustin!
Cool script Idea.. I'll take a look..
It seems like the "Edit Window View selector" popup menu is a little diferent to a standard popup menu. But I'm sure there is a workaround.
Stand by......... :-)
- In reply toDustin_Harris⬆:
Kitch Membery @Kitch2020-06-05 02:42:59.253ZDustin...
This fixes it by using the menu item selector instead of the "Edit Window View selector" popup.
sf.ui.proTools.appActivateMainWindow(); const checkBoxes = [ { Title: 'Comments', State: "Enable" }, { Title: 'Mic Preamps', State: "Enable" }, //{ Title: 'Instrument', State: "Enable" }, { Title: 'Inserts A-E', State: "Enable" }, { Title: 'Inserts F-J', State: "Enable" }, { Title: 'Sends A-E', State: "Enable" }, { Title: 'Sends F-J', State: "Enable" }, { Title: 'I/O', State: "Enable" }, { Title: 'Object', State: "Enable" }, { Title: 'Real-Time Properties', State: "Enable" }, { Title: 'Track Color', State: "Enable" }, ]; checkBoxes.forEach(setCheckboxState); function setCheckboxState(item) { sf.ui.proTools.menuClick({ menuPath: ['View', 'Edit Window Views', item.Title], targetValue: item.State, }) }I commented out the Instrument track item in the checkBoxes object as it was not finding any Instrument tracks in my session, so some logic may need to be added to fix this.
Rock on!PS. All your other logic was spot on. :-)
Kitch Membery @Kitch2020-06-05 03:10:01.416ZYou can un-comment the Instruments item in the "checkBoxes" object and then add
onError:"Continue",to themenuClickand you are good to go!sf.ui.proTools.appActivateMainWindow(); const checkBoxes = [ { Title: 'Comments', State: "Enable" }, { Title: 'Mic Preamps', State: "Enable" }, { Title: 'Instrument', State: "Enable" }, { Title: 'Inserts A-E', State: "Enable" }, { Title: 'Inserts F-J', State: "Enable" }, { Title: 'Sends A-E', State: "Enable" }, { Title: 'Sends F-J', State: "Enable" }, { Title: 'I/O', State: "Enable" }, { Title: 'Object', State: "Enable" }, { Title: 'Real-Time Properties', State: "Enable" }, { Title: 'Track Color', State: "Enable" }, ]; checkBoxes.forEach(setCheckboxState); function setCheckboxState(item) { sf.ui.proTools.menuClick({ menuPath: ['View', 'Edit Window Views', item.Title], targetValue: item.State, onError:"Continue", }) }
Kitch Membery @Kitch2020-06-05 03:24:41.119Z@Dustin_Harris... I accidently replied to my own post... Above is the fix for the Instrument menu item. :-)
- In reply toKitch⬆:
Dustin Harris @Dustin_HarrisAwesome! Thanks Kitch, I completely forgot those options were mirrored in the drop down menu!
Also... it wasn't my logic, it was yours :).
Kitch Membery @Kitch2020-06-05 03:21:27.736ZBahahahhaha! Well your adaptation was spot on. :-)
Easy oversight on the menu thing... there are so many ways to do the same thing in Pro Tools.
Dustin Harris @Dustin_HarrisonError is nice, I wouldn't have thought of that. I'd probably do something like:
if (sf.ui.proTools.getMenuItem('View', 'Edit Window Views', item.Title).exists) {}This is part of a larger script that I use to reset sessions i receive from ADR shops. Sets the track headers, blows away their IO, and turns the scrolling off :)
Kitch Membery @Kitch2020-06-05 03:45:50.582ZThat’s a much better way to deal with it. Your script is gonna save you some mouse click for sure!!! :-)