I have a script that enables record + input but the input is failing to be activated. The script enables Record in a MIDI track and also enables record and input in an Audio track to pass through the midi as audio. This is the script I use:
const targetTrackName = "Footsteps 1";
/**
* @param {Object} obj
* @param {AxPtTrackHeader} obj.track
* @param {'Enable'|'Disable'|'Toggle'} [obj.targetValue]
*/
function trackSetRecordEnable({ track, targetValue = "Toggle" }) {
const btn = track.buttons.whoseTitle.is("Track Record Enable").first;
const btnName = btn.title.invalidate().value;
const isSelected = btn.value.invalidate().value === "on state";
const clickButton = () => btn.elementClick({}, `Could not click the button titled ${btnName}.`);
if (targetValue === "Enable" && !isSelected || targetValue === "Disable" && isSelected || targetValue === "Toggle") {
clickButton();
}
}
/**
* @param {Object} obj
* @param {AxPtTrackHeader} obj.track
* @param {'Enable'|'Disable'|'Toggle'} [obj.targetValue]
*/
function trackSetInputMonitor({ track, targetValue = "Toggle" }) {
const btn = track.buttons.whoseTitle.is("TrackInput Monitor").first;
const btnName = btn.title.invalidate().value;
const isSelected = btn.value.invalidate().value === "on";
const clickButton = () => btn.elementClick({}, `Could not click the button titled ${btnName}.`);
if (targetValue === "Enable" && !isSelected || targetValue === "Disable" && isSelected || targetValue === "Toggle") {
clickButton();
}
}
function main() {
sf.ui.proTools.appActivateMainWindow();
// Invalidate the main window incase the tracks have changed
sf.ui.proTools.mainWindow.invalidate();
const track = sf.ui.proTools.trackGetByName({ name: targetTrackName }).track;
// Enable Record on Track
trackSetRecordEnable({ track, targetValue: "Enable", });
// Enable Input monotoring on Track
trackSetInputMonitor({ track, targetValue: "Enable", });
}
main();
Linked from:
- Kitch Membery @Kitch2024-11-14 20:37:03.315Z
In Pro Tools 2024.10, Avid changed the name of the UI Element under the hood for the Input Monitor.
Replacing the
trackSetInputMonitor
function with this script should fix the issue./** * @param {Object} obj * @param {AxPtTrackHeader} obj.track * @param {'Enable'|'Disable'|'Toggle'} [obj.targetValue] */ function trackSetInputMonitor({ track, targetValue = "Toggle" }) { const btn = track.buttons.whoseTitle.startsWith("Input monitoring").first; const btnName = btn.title.invalidate().value; const isSelected = btn.value.invalidate().value === "on"; const clickButton = () => btn.elementClick({}, `Could not click the button titled ${btnName}.`); if (targetValue === "Enable" && !isSelected || targetValue === "Disable" && isSelected || targetValue === "Toggle") { clickButton(); } }
Let me know if it works for you. :-)
- DDaniel Betancourt @Daniel_Betancourt6
Thanks Kitch,
It does not seem to work. I pasted your script on top of the TrackSetInputMonitor function, but it does not activate the input. Only the record.Kitch Membery @Kitch2024-11-14 21:41:12.790Z
Hmmm, I must have made an error somewhere. I shall take another look this afternoon. :-)
- In reply toDaniel_Betancourt6⬆:
Kitch Membery @Kitch2024-11-14 21:43:36.131Z
I think I only tested the function's targetValue set to"Toggle"...
My bad. I shall report back this afternoon with a new and improved version. :-)
- In reply toDaniel_Betancourt6⬆:
Kitch Membery @Kitch2024-11-14 22:16:03.785Z
I just tested my code and it seems to be working.
Just in case here is the full script.
const targetTrackName = "Footsteps 1"; /** * @param {Object} obj * @param {AxPtTrackHeader} obj.track * @param {'Enable'|'Disable'|'Toggle'} [obj.targetValue] */ function trackSetRecordEnable({ track, targetValue = "Toggle" }) { const btn = track.buttons.whoseTitle.is("Track Record Enable").first; const btnName = btn.title.invalidate().value; const isSelected = btn.value.invalidate().value === "on state"; const clickButton = () => btn.elementClick({}, `Could not click the button titled ${btnName}.`); if (targetValue === "Enable" && !isSelected || targetValue === "Disable" && isSelected || targetValue === "Toggle") { clickButton(); } } /** * @param {Object} obj * @param {AxPtTrackHeader} obj.track * @param {'Enable'|'Disable'|'Toggle'} [obj.targetValue] */ function trackSetInputMonitor({ track, targetValue = "Toggle" }) { const btn = track.buttons.whoseTitle.startsWith("Input monitoring").first; const btnName = btn.title.invalidate().value; const isSelected = btn.value.invalidate().value === "on"; const clickButton = () => btn.elementClick({}, `Could not click the button titled ${btnName}.`); if (targetValue === "Enable" && !isSelected || targetValue === "Disable" && isSelected || targetValue === "Toggle") { clickButton(); } } function main() { sf.ui.proTools.appActivateMainWindow(); // Invalidate the main window incase the tracks have changed sf.ui.proTools.mainWindow.invalidate(); const track = sf.ui.proTools.trackGetByName({ name: targetTrackName }).track; // Enable Record on Track trackSetRecordEnable({ track, targetValue: "Enable", }); // Enable Input monotoring on Track trackSetInputMonitor({ track, targetValue: "Enable", }); } main();
- DDaniel Betancourt @Daniel_Betancourt6
Perfect! Now it works! Thanks so much!
Kitch Membery @Kitch2024-11-14 22:58:31.045Z
Awesome! Glad it worked. :-)
- Bbenjamin.lemoine @benjamin_lemoine
Hi Kitch, first of all thank you for your contribution !
Is there any solution to apply this script with a selection of track with inputName ?Kitch Membery @Kitch2024-11-19 18:35:42.581Z
Could you provide a bit more context about what you are trying to achieve and the manual steps you would take to achieve it? I think I understand, but additional details could clarify things further.