KM macro to switch Stream Deck Profiles works but is slow

I find that the most tedious aspect of Stream Deck devices is constantly pressing buttons to switch profiles.

Switching profiles is automatic when the profile is app related, but manual when the profile pertains to non app issues, like (in my case) a font profile, a formatting profile, a search and replace profile, etc.

Trying to address the Stream Deck directly with KM seems (from my reading) heroic and beyond my intellectual capabilities.

To bypass the latter, I had the idea of switching profiles via the Stream Deck status menu and wrote the following macro.

It works, but is slow and I was wondering if forum members have an idea as to how to improve it.

thanks in advance for your time and help

Format Profile Stream Deck.kmmacros (28.8 KB)

2024-04-28_16-54-09

App switching is still the way to go, all you have to do is create one / more 'dummy' apps that represent the profile you want to load, and have KM 'open' that app to trigger the StreamDeck profile.

It only takes a couple minutes to set up and it's well worth it.

I'll dig up the thread that describes how to create the dummy apps

3 Likes

incredible. I look forward to seeing how you create dummy apps. thank you very much

Isn't the profile then only active while the dummy app is frontmost? That was the approach I took first, creating a dummy app in AppleScript, but the profile would activate then deactivate as soon as the dummy app quit.

I think this method is marginally faster than the original: Put the keystrokes in the AppleScript, too:

tell application "System Events"
	tell process "Stream Deck"
		click menu bar item 1 of menu bar 2
		keystroke "F"
		keystroke return
	end tell
end tell

There's no need to type the entire word Format, as the name is unique and F will get there. It's still slow, though, as the Stream Deck menu seems to have some sort of delay built into it that other menu extras don't have. (I have a simple six-button Stream Deck I use for testing our apps with the thing.)

-rob.

1 Like

Posted above (edited my post with the link). You can scan the (long) thread for how folks arrived there, but tbh, nobody has come up with a better solution. It feels very hacky, but darned if it doesn't just work.

2 Likes

I don't have StreamDeck with me on this machine rn (laptop on the road) but there is a way to configure it so that it doesn't 'exit' the profile. I think the way you do it is you don't assign a 'default' profile (this really is off the top of my head) and that means SD will just stay in whatever the last profile you loaded is, until you raise another app that triggers a profile (which is what you want anyway)

2 Likes

Simply create a new AppleScript in script editor. Type "1 = 1" and save it as an application. Associate a Stream Deck profile with that and you're set.

2 Likes

I just put a comment in my dummy app:

-- This app does nothing.

I wonder if doing math is quicker than interpreting text? :slight_smile:

That was it! Uncheck the "Make this my default profile" box so no profiles are default, and it'll stay in whatever it gets assigned to. With that, dummy apps are definitely the way to go. Instantaneous switching.

-rob.

2 Likes

I think that your solution is the one that suits me the best, but that you @johns for your suggestion.

I would have 2 follow-up questions if you have the patience. I want to use your AppleScript

  • what if multiple profiles start with the same letter (I only listed the first 3 of my profiles). What would be the AppleScript command to for example type "default" ? for a few letters like "def"?

  • with your script (that I prefer) there is a delay between

tell application "System Events"
	tell process "Stream Deck"
		click menu bar item 1 of menu bar 2

and

keystroke "F"
		keystroke return
	end tell
end tell

If the delay was shorter, your script would be absolutely perfect. Is there any way to shorten it ?

thanks again

You really should use the dummy app method. Just download the attached and unzip it. Put it in a Dummy Apps folder, and duplicate it for as many profiles as you have. Rename each to match a profile (just to make setup easier), then edit the SD profiles to activate each dummy app.

DoNothingApp.zip (50.3 KB)

If you put the text directly in the AppleScript, you'd have to keystroke each letter, probably with a very small pause between each:

keystroke "d"
pause .05
keystroke "e"
pause .05
etc

If I were doing it this way, though, I'd just rename my profiles to start with unique letters or numbers—numbers would be great if you have 10 or less.

This is what I mentioned above: The delay is intrinsic to the Stream Deck menu extra. It's not added by the script, it's not added by Keyboard Maestro, and it's not seen when using other menu extras. There's no way to avoid it.

That's why the dummy apps really are the best way to go—the switching is instantaneous with app launch (and the app then instantly quits, as it's just a one-line comment).

-rob.

1 Like

thank you @griffman and thank you @johns for having the best solution. I changed my mind and will go with the dummy apps

2 Likes

Just a warning, @ronald, that you may fall foul of quarantine issues with @griffman's download. It really is easy to make your own app though -- just open Script Editor, type in

-- this app does nothing

...then "Save" and select "File Format: Application" (leave the options unticked):

2 Likes

Don't forget to check 'Stay open after run handler'. I've had problems with apps bouncing and not triggering the macro without that checked

1 Like

Yep, simple -- extraordinarily un-elegant -- and still works after years.

1 Like

I admit I just started using this today, but so far, I've not had any issues with the profiles not sticking. Maybe put a pause action in to wait a second or so? It'd be annoying to have to leave all those dummy apps running.

-rob.

1 Like

this was years ago and maybe things have changed. I just remember that I needed to do that .. (the script itself did exit, so the app did close, but it reliably trigger KM... so who knows.. heh)

1 Like

Weird! Only time I've ever checked that box is when there's an idle handler in the app, so it needs to stay open "waiting" for something (if it's not ticked the app quits after the run handler completes).

1 Like

I have a 15 Mk2, a 32 XL and the mobile (2x64) on a big iPad.
For jumping to other profiles easy, I kept the process internal to the Streamdeck by following this guy's video.

Good luck with whichever way you decide to workflow.

I am using the iPad in a 4x8 Stream Deck arrangement and I love it. I'm still paying the monthly fee every month. I'm stingy and don't like subscriptions, but this one I've kept for about 6 months so far.

I experimented with the "profiles" feature but I didn't like it. Instead, I built my own way to create profiles. It's still experimental, as I build up its features, but I have no interest in using the vendor's profiles when I can have full control over all the buttons on my own. I essentially store my own profiles as entries in a KM dictionary. When I want to switch profiles, I just call a macro with my own profile name, and all 32 buttons are redrawn in less than a second.

1 Like

They have a lifetime purchase option now of US$49

2 Likes