No internet connection
  1. Home
  2. How to

Hold SHIFT on stream deck? Am I doing this right?

By Owen Granich-Young @Owen_Granich_Young
    2021-11-18 18:44:21.805Z

    Hello,

    I have a DX Layout script that's working smoothly, here's my deck. If I hold keyboard modifier SHIFT when I run it it will mute the Audio after moving it (oftentimes I want both mics in the show but only one unmuted)

    It gets a bit cumbersome to reach over to my deck and hold the keyboard shift button sometimes, so I'd very much like to put keyboard SHIFT button on my stream deck.

    I've tried this very simple marco :

    But it is not producing the desired result. What am I doing wrong and is there a better way to go about implementing this?

    Thanks!
    Owen

    • 8 replies
    1. For this, I would instead consider setting a globalState variable to true/false that you can then check in the other script.
      This would require you to use scripts, not macros though. The upcoming version of SF will make this easier to do in a macro.

      1. So a stream deck button that would 'set global state variable' ?

        Or, instead of my If/else in the main script it needs to be a check global state kind of code instead? And then the global button would work?

        Main script , mostly just a duplicate copy/paste/modify of Kat's copy to track scirpt with an IF/ELSE and one extra line of code in the second one to mute region. I'm sure there's a much slimmer version of it. (I'm sure even looking at it will make your head explode, 😂)

        const { trackToPasteTo } = event.props
        
        var s = sf.ui.proTools;
        s.appActivateMainWindow();
        s.mainWindow.invalidate();
        
        const modifierState = event.keyboardState.asString
        
        switch (modifierState) {
            case "shift":
                // Check that Link Track and Edit Selection is selected, if not, select it (will de-select after command)
                const btn = s.mainWindow.cursorToolCluster.buttons.whoseTitle.is('Link Track and Edit Selection').first;
                var needToDeactivate = false
        
                //This will activate the button
                if (btn.value.invalidate().value !== 'Selected') {
                    btn.elementClick();
                    needToDeactivate = true
                }
        
                const originalTrack = s.trackGetSelectedTracks()
        
                s.menuClick({
                    menuPath: ['Edit', 'Cut']
                });
        
                // Selects the track to paste to based on the name you've entered
                // Remove trailing ' - Audio Track' from track title to get track name
                const t = trackToPasteTo.title.Value
                var slicedName = t.slice(0, t.indexOf(" - Audio Track"))
        
                const newTrack = s.trackSelectByName({
                    names: [slicedName],
                    deselectOthers: true,
                })
        
        
                // Weird hack to make copying from a playlist alternative work. 
                // This puts the cursor on the track to be pasted to by simulating the cursor move down then back up
                // to the selected track. Only then will pasting work.
                sf.keyboard.press({
                    keys: "semicolon,p,v",
                });
        
                sf.ui.proTools.menuClick({
                    menuPath: ["Edit", "Mute Clips"],
                });
        
        
                // Makes sure original track is selected again
        
                s.trackSelectByName({ names: originalTrack.names.slice(0), deselectOthers: true })
                s.selectedTrack.trackScrollToView()
        
                if (needToDeactivate) {
                    log('need to deactivate')
                    btn.elementClick();
                }
                break
        
            case "":
                // Check that Link Track and Edit Selection is selected, if not, select it (will de-select after command)
                const btn = s.mainWindow.cursorToolCluster.buttons.whoseTitle.is('Link Track and Edit Selection').first;
                var needToDeactivate = false
        
                //This will activate the button
                if (btn.value.invalidate().value !== 'Selected') {
                    btn.elementClick();
                    needToDeactivate = true
                }
        
                const originalTrack = s.trackGetSelectedTracks()
        
                s.menuClick({
                    menuPath: ['Edit', 'Cut']
                });
        
                // Selects the track to paste to based on the name you've entered
                // Remove trailing ' - Audio Track' from track title to get track name
                const t = trackToPasteTo.title.Value
                var slicedName = t.slice(0, t.indexOf(" - Audio Track"))
        
                const newTrack = s.trackSelectByName({
                    names: [slicedName],
                    deselectOthers: true,
                })
        
        
                // Weird hack to make copying from a playlist alternative work. 
                // This puts the cursor on the track to be pasted to by simulating the cursor move down then back up
                // to the selected track. Only then will pasting work.
                sf.keyboard.press({
                    keys: "semicolon,p,v",
                });
        
                // Makes sure original track is selected again
        
                s.trackSelectByName({ names: originalTrack.names.slice(0), deselectOthers: true })
                s.selectedTrack.trackScrollToView()
        
                if (needToDeactivate) {
                    log('need to deactivate')
                    btn.elementClick();
                }
                break
            case "alt+shift": // two modifiers!
                log("Alt & Shift are held down");
                break
        };
        
        1. Or, instead of my If/else in the main script it needs to be a check global state kind of code instead?

          Yes, exactly :)

            1. Hmmmm...

              1. Apologies, it was in a closed portion of the forum, moved it out now

                1. Thanks, ok I think I get it? Basically my 'mute modifer' button would be the globalState.unbypassWhenOpenSend = !globalState.unbypassWhenOpenSend; part and then I'd figure out how to re-code the other one to check which status the toggle buton is.

                  I'll take a stab at this when I have some time.

                  Owen

                  1. Yes exactly :)