Is there a way to add a button on my stream deck to turn the application trigger of a shortcut on/off.
I'm thinking of the "Output window follow selection" command. That can't have a standard trigger as it needs to allways be on or off.
Linked from:
- Christian Scheuer @chrscheuer2020-02-23 03:05:06.992Z
Hi Emil.
Right now there's no function in SoundFlow to control the enabled state of other triggers, but we will likely add that some time in the future.
For now what you need is to use a globalState variable to toggle whether or not that other script should work or not. So you'll have two scripts, one that toggles the "on/off state" but it saves this info in a global state variable, that is then read by the "Output window follow selection" script (which will need to be modified).
Christian Scheuer @chrscheuer2020-02-23 21:51:12.166Z
Which of the Output window follow selection scripts are you using? One from the forum or from my package?
If you share the script here I can help you add the needed code.
- SIn reply tostudiomollan⬆:Emil Isaksson @studiomollan
Hi!
It's from the "pro tools utilities 10.0.17" Not sure thats one of yours or the forum. Think the later.
Heres the script.Christian Scheuer @chrscheuer2020-02-23 22:58:02.419Z
Can you copy/paste the script so I don't have to rewrite it line by line?
- SEmil Isaksson @studiomollan
var lastFocusedTrackName; function main() { try { var newName = sf.ui.proTools.selectedTrackNames[0]; if (newName === lastFocusedTrackName || newName === undefined) return; lastFocusedTrackName = newName; if (sf.ui.proTools.selectedTrack.outputWindowButton.value.invalidate().value !== 'open') sf.ui.proTools.selectedTrack.trackOutputToggleShow({ onError: 'Continue' }); } catch (err) { } } 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(); globalState[name] = (new Date).valueOf(); action(); sf.wait({ intervalMs: interval, executionMode: 'Background' }); } } finally { globalState[name] = null; } }); } runForever("isFollowFocusedTrackRunning", main, 500, 5000);
Christian Scheuer @chrscheuer2020-02-23 23:08:58.785Z
Okay. Create a new script and use this instead (ie. remove triggers to the existing script and move them over to this new one):
var lastFocusedTrackName; function main() { try { var newName = sf.ui.proTools.selectedTrackNames[0]; if (newName === lastFocusedTrackName || newName === undefined) return; lastFocusedTrackName = newName; if (!globalState.isFollowFocusedTrackActive) return; if (sf.ui.proTools.selectedTrack.outputWindowButton.value.invalidate().value !== 'open') sf.ui.proTools.selectedTrack.trackOutputToggleShow({ onError: 'Continue' }); } catch (err) { } } 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(); globalState[name] = (new Date).valueOf(); action(); sf.wait({ intervalMs: interval, executionMode: 'Background' }); } } finally { globalState[name] = null; } }); } runForever("isFollowFocusedTrackRunning", main, 500, 5000);
Now, create yet one more script that you call "Toggle Follow Focused Track" and put this code in there:
globalState.isFollowFocusedTrackActive = !globalState.isFollowFocusedTrackActive; log(`Follow Focused Track is now: ${globalState.isFollowFocusedTrackActive ? 'ON' : 'OFF'}`);
This 2nd script toggles whether or not the 1st script should do the following or not.
- SIn reply tostudiomollan⬆:Emil Isaksson @studiomollan
It just looks weird when i do it.
Christian Scheuer @chrscheuer2020-02-23 23:05:27.219Z
I've edited your post now. You can format code in the forum by having three back ticks on a separate line before and after the code:
```
To see it for yourself, try editing your post, you can see how I formatted yours.
- S
- SEmil Isaksson @studiomollan
Too late to try this out now but I'll get to to it by tomorrow.
Thank you Christian!
- SIn reply tostudiomollan⬆:Emil Isaksson @studiomollan
Works Great!!! Exactly what i wanted!
Christian Scheuer @chrscheuer2020-02-24 18:37:16.841Z
Awesome!