Hello!
I'd like to use Protools Playback as a "Trigger" to fire a Keycommand
So it should Fire the Keycommand when Protools Playback Starts and another one when Protools Stops
(I Want to toggle the Microphone inside Zoom to Mute for Online Mixing Sessions)
I'm Now doing it with the Spacebar as the Trigger wich is not Ideal as i can not type then in Protools.
Any Help would be wonderful! Thank you!
all the best! giuli
- samuel henriques @samuel_henriques
This script will run in the backgroung and log "Playing" when pro tools starts playing and log "Stoped" when you stop pro tools.
Replace the "log" lines with the code you need.Let me know how it goes
let currentPlayState function main() { if (sf.ui.proTools.invalidate().exists) { if (sf.ui.proTools.mainWindow.sessionPath != null) { const playState = sf.ui.proTools.isPlaying if (currentPlayState != playState) { currentPlayState = playState if (playState) {// If pro tools is playing sf.keyboard.press({ keys: "ctrl+cmd+alt+shift+x", fast: true }); //log("Playing") // Your code here } else if (!playState) {// If pro tools is stoped sf.keyboard.press({ keys: "ctrl+cmd+alt+shift+x", fast: true }); //log("Stoped") // Your code here } } } } } function runForever(name, action, interval, timeout) { var now = (new Date).valueOf(); if (now - globalState[name] < timeout) throw 0; //Exit if we were invoked again inside the timeout globalState[name] = now; sf.engine.runInBackground(function () { try { while (true) { sf.engine.checkForCancellation(); action() sf.wait({ intervalMs: interval, executionMode: 'Background' }); } } catch (e) { log("Run forever has ended!") } finally { globalState[name] = null; } }); } runForever("play_Stop", main, 500, 5000);
- GGiuliano Sulzberger @Giuliano_Sulzberger
Very Good! It works! Thank you Samuel!
For everybody that is interested.
I just put a Shortcut into Zoom that works even when Zoom is not in Focus (Its in the Zoom Settings) That will be triggered with the Code from Samuel. I find it to be very practical i used it a bunch last week.- I do still get a error message when i start protools and when i stop it because the Scrip is running before protools does. Im not sure if i can get a "wait" in there somehow. (I do not programm at all. total noob here)
samuel henriques @samuel_henriques
hello @Giuliano_Sulzberger,
great it's working, do you get error every time you press play and stop?
could you share the code?samuel henriques @samuel_henriques
UPDATED ABOVE: no more error and script fail when you open and close sessions.
- GGiuliano Sulzberger @Giuliano_Sulzberger
Super! No Error in on Starting Protools. But there is one on Closing Protools. Not so bad.
I tried also to take out the LogInfoBubble Thingy that comes up on the corner of the screen by deleting log("Playing")
I probably broke something. So here is the code that i used after that. (With your update)
function runForever(name, action, interval, timeout) {
var now = (new Date).valueOf();
if (now - globalState[name] < timeout) throw 0; //Exit if we were invoked again inside the timeoutglobalState[name] = now; sf.engine.runInBackground(function () { try { while (true) { sf.engine.checkForCancellation(); action() sf.wait({ intervalMs: interval, executionMode: 'Background' }); } } finally { globalState[name] = null; } });
}
function main() {
if (sf.ui.proTools.mainWindow.sessionPath != null) { const ptIsPlaying = sf.ui.proTools.isPlaying if (globalState.playState != ptIsPlaying) { if (ptIsPlaying) {// If pro tools is playing // // sf.keyboard.press({ keys: "ctrl+cmd+alt+shift+x", fast: true, }); } else if (!ptIsPlaying) {// If pro tools is stoped // // sf.keyboard.press({ keys: "ctrl+cmd+alt+shift+x", fast: true, }); } } globalState.playState = ptIsPlaying }
}
runForever("play_Stop", main, 500, 5000);
samuel henriques @samuel_henriques
no error on my side, the code as you posted looks correct.
could you start the code text on the first line of the editor and let me know what is the error and error line?
in the mean time, here's a great video from Kitch explaining how to quote code on the forum:
How to quote code in the SoundFlow forum.- GGiuliano Sulzberger @Giuliano_Sulzberger
Ah very good. I was wondering if it was readable that way.!
It just tells me 14.04.2021 09:09:04.93
[Backend]: AXUIElementException in LoadUIElement: kAXErrorCannotComplete AXUIElementException in LoadUIElement: kAXErrorCannotComplete
when i close protools. I dont know what it means i cant find any of this things in the code.
All the best!
Giulifunction runForever(name, action, interval, timeout) { var now = (new Date).valueOf(); if (now - globalState[name] < timeout) throw 0; //Exit if we were invoked again inside the timeout globalState[name] = now; sf.engine.runInBackground(function () { try { while (true) { sf.engine.checkForCancellation(); action() sf.wait({ intervalMs: interval, executionMode: 'Background' }); } } finally { globalState[name] = null; } }); } function main() { if (sf.ui.proTools.mainWindow.sessionPath != null) { const ptIsPlaying = sf.ui.proTools.isPlaying if (globalState.playState != ptIsPlaying) { if (ptIsPlaying) {// If pro tools is playing // // sf.keyboard.press({ keys: "ctrl+cmd+alt+shift+x", fast: true, }); } else if (!ptIsPlaying) {// If pro tools is stoped // // sf.keyboard.press({ keys: "ctrl+cmd+alt+shift+x", fast: true, }); } } globalState.playState = ptIsPlaying } } runForever("play_Stop", main, 500, 5000);
samuel henriques @samuel_henriques
can't figure this out, could I ask you to report on Help/Issue just after getting the error, so @Kitch or @chrscheuer can have a better view of what's happening there?
- In reply toGiuliano_Sulzberger⬆:
samuel henriques @samuel_henriques
Hello @Giuliano_Sulzberger ,
I think I got it, and made a slight improvement to the script.
It's updated above.Let me know how it goes
- MIn reply toGiuliano_Sulzberger⬆:Michael Hartung @Michael_Hartung
I really want to get this to work, but I don't understand what it means to "Replace the "log" lines with the code you need." What code do I need other than this script? I basically want what the original poster wanted, every time I press play on protools, it mutes the Zoom app microphone, and when I stop, it unmutes it. Is this script missing something to make that work? I've honestly read all the posts, but couldn't make sense of it. Looking for some help.
Thanks!! - GIn reply toGiuliano_Sulzberger⬆:Graham Archer @Graham_Archer
@samuel_henriques this is so good!
Has anyone amended this code so that it works with Logic Pro X do you know?
It would be really useful as well.Thanks so much