Hi! I want to build a script that will toggle between two decks (neither have 'back' buttons)
Is there a way to programmatically tell which deck is currently open/displayed?
sorry for the pseudo-code:
let currentDeck = "Currently Displayed Deck" //currently displayed deck commandID
let deck_one = "open this deck" //commandID for deck one
let deck_two = "open that deck" //commandID for deck two
if (currentDeck === deck_one) {
//..open deck_two
} else {
//..open deck_one
}
Thanks!
- AAndrew Skipper @Andrew_Skipper
You can auto switch Deck dependent on window and app open?
- Dustin Harris @Dustin_Harris2021-04-04 21:26:21.729Z
Heyya! Thats a great suggestion, but I'm not actually switching any windows for it, I basically want to use two different decks in the same program and switch back and forth between them, and to get the logic to work I need to be able to programmatically tell which deck is the one currently open :) I just don't know how to do that...
- In reply toDustin_Harris⬆:Christian Scheuer @chrscheuer2021-04-04 22:10:05.664Z
You can get the
currentDeckInstance
to get a handle to the AxDeckInstance, and then look inside the full instance ID (the command ID of the deck is part of the instance ID):log(sf.devices.streamDeck.firstDevice.currentDeckInstance.fullInstanceId);
- Christian Scheuer @chrscheuer2021-04-04 22:10:42.710Z
If you're looking for loaded deck instances on a mobile device, use this:
sf.devices.mobile.connectedDevices[0]
Edit: Ah, I don't think you actually have access to it through that mechanism.
- Christian Scheuer @chrscheuer2021-04-04 22:14:25.790Z
Also. Remember that if your script is being run by pressing a command on the deck itself, you can just read from
event.deck
.Finally, you could instead opt to store which deck you're showing in a globalState variable that you set in the same script/macro that you use to show the deck. That way you have full control yourself.
- Dustin Harris @Dustin_Harris2021-04-04 22:48:44.631Z
Oh, that's brilliant! I'd have to work out how to deal with unsynchronized deck / globalState variable, but that is definitely a cool way to approach it!