Refresh a Streamdeck button

Hallo,

questions about the Streamdeck button. (I use BTT plugin Stream Deck option)

Is there a way to refresh a Streamdeck button (with Java script or so) so that a different Icon/color/Text is displayed, depending on a custom variable ?

When I have conditions defined for two buttons (see screen) always the second is displayed, while the condition is not true (the variable play is 'off' ).

who would be able to help ?

thx,
Christian

Running:
BTT 3.9993 (2193) / Mac M1 Max OS 13.2 (22D49)
BTT plugin Stream Deck option
Stream Deck Mobile (on iPad Air) latest version

1 Like

Have you tried this one?

Bildschirmfoto von BetterTouchTool (20-01-23, 18-18-49)

Bildschirmfoto von IINA (20-01-23, 18-22-37)

Hallo,

Yes, thanks. I have used/tested the "Toggle on/off button", and it works fine as such,
but not quite for my purposes..

Here is my use case:
I use StreamDeck & BTT with Ableton Live (DAW for music production).
'Playing/stopping' a track in Ableton can be done with:

  • the keyboard spacebar
  • with the mouse hitting the 'play icon' on sceen
  • via the various MIDI controllers
  • and also via one of my BTT Java scripts to trigger actions

I want to reflect that 'play/stop' state on the Streamdeck button
( with a green/red icon/text for example ).

When I would use only Streamdeck to 'play and stop', the "Toggle on/off button" works fine, but when I 'stop' the track via the Spacebar/Mouse/MIDI controller, the Streamdeck button is not updated/synced…(which is obvious).

In BTT I have a Java script which checks the color of the 'play' button on a given x/y position on screen.

So I 'know' in BTT what the play/stop state of Ableton is, which I would like to use to change/refresh ( somehow ) a SD button dynamically.

There is another issue with the BTT "Toggle on/off button" for my case:
I have a 'play' button on differnent pages in the Streamdeck and those are not in sync with each other.
For example: One shows play and when changing in SD to a different page that play button on that page still shows 'stop'.

anyway, thanks again.
Christian

Running:
BTT 3.9993 (2193) / Mac M1 Max OS 13.2 (22D49)
BTT plugin Stream Deck option
Stream Deck Mobile (on iPad Air) latest version

ha,
I guess I found the solution...(i.e next time I better read the documentation properly...)
the Apple Script Widget will do the trick...brilliant...

You can also always use the
update_stream_deck_widget script call, or to permanently update a trigger the update_triggerfunction.
If you just want to run the Apple Script of a script widget to refresh it, you can use the refresh_widget function.

See Using Apple Script or JXA · GitBook

Hallo Andreas,

thanks a lot. Everything works fine now.

…question about the "Excecute script every X seconds"
incombination with the "[X] Always run when widget becomes visible" to fully
understand the behavior.

Does "Excecute script every 2 seconds" runs the script always every 2 sec even when the widget/button is not visible on Streamdeck ?

Thx,
Christian

Running:
BTT 3.9993 (2193) / Mac M1 Max OS 13.2 (22D49)
BTT plugin Stream Deck option
Stream Deck Mobile (on iPad Air)

It will only run if the button is visible

I have a similar situation with zoom where I use a Toggle On/Off to set the mute status. I find that setting the mute status through AppleScript isn't a 100% reliable, occasionally it doesn't set it for some unknown reason. Also rapidly clicking the stream deck button twice can result in the stream deck button and zoom status becoming out of sync.

Am I right in thinking I should be using blocking scripts and not asynchronous scripts for the toggle on/off action?

Secondly if I wanted another script to run every second or so, where would be the optimal place to add this? Can I add it as another action besides the Toggle on/off, or does it need to be assigned to another button?
Is my expectation of a system with an always correct stream deck button realistic? Is there a better system than AppleScript to optimise the alignment of these two user interface elements?

This is the script I use to set the mute status, the one for unmute is very similar with exception for the menu item it activates.

tell application "System Events"
	if exists window 1 of process "zoom.us" then
		tell application process "zoom.us"
			if exists (menu 1 of menu bar item "Meeting" of menu bar 1) then
				
				set meetingMenu to menu 1 of menu bar item "Meeting" of menu bar 1
				set canMute to exists menu item "Mute audio" of meetingMenu
				set canUnmute to exists menu item "Unmute audio" of meetingMenu
				
				if canMute then
					click menu item "Mute audio" of meetingMenu
				end if
			end if
		end tell
	end if
end tell