Trigger Macro Once When Switching to Application?

Hi @johns,

Yes, that would be the case ordinarily. However, if you want to use @ncbasic's idea to use blank apps to trigger profiles, you don't necessarily want Logic to automatically trigger its associated SD profile every time it comes into focus, as that undoes the manual trigger you'd just run.

Does that make sense?

Thanks to @ncbasic and @ccstone, my SD now displays my Logic profile when plugin windows are not in focus. If I click on a plugin that has a dedicated SD profile, it loads it; if it doesn't, it loads my generic plugin profile that contains common controls. This is all in the service of being able to use my nObcontrol with as little time looking at the screen and as few extraneous button pushes as possible... so far so good!

Here's where I got to. Attached are the two profile trigger macros: one for Logic and one for plugins. Also included are the two loop-break sub-macros.

The only minor drawback is that, due to the loop-break pauses, profiles can't trigger in quick succession. If, for example, you click on one plugin and then another within the pause duration (which is necessarily 1 second or longer), the first plugin's profile will persist. Then it's a case of clicking back and forth until they work themselves out. I can live with that, but if anyone has a eureka moment and can think of a way to avoid feedback loops without pauses, do chip in!

Logic - Stream Deck Profile Macros.kmmacros (21.4 KB)

Also, if anyone knows how to make a bunch of exceptions for which windows won't trigger the macro without a giant list like this, that would make the macro a lot easier to look at. After reading this, I tried adding them all to one entry like this: tracks|mixer|event list|preferences|edited ...but it didn't work. Again, a minor complaint.

image

I've been trying (and failing) to set up a window blacklist but I think a neater idea might be to detect whether a UI element exists in the front window.

Do you know if there's a way to detect whether a UI element exists in the front window?

Window Analysis Tool returns this for a plugin window:

	window Output 1-2
		button 1
		button 2
		checkbox "Button"
		menu button "Editor"
		static text "View:"
		pop up button 1
		static text "Side Chain:"
		checkbox "Button"
		checkbox "Compare"
		group 1
			button 1
			button 2
		group 2
			button "Copy"
			button "Paste"
		group 3
			button "Undo"
			button "Redo"
		pop up button 2
		static text "Output 1-2"

Hey Neil,

Clearly there are detectable elements. Run this in Script Debugger, and see what you get.

-Chris

tell application "System Events"
   tell application process "Logic Pro"
      properties of pop up button 1
   end tell
end tell

In that post the condition was added to a macro Group.

Applescript to me is like Greek to a Martian, but I'm wondering if it needs a "tell front window" thing in there? :man_shrugging:t2:

You're quite right.

That's what I get for writing code for an application I don't have...

Sorry mate I'm not sure what you mean. It was a condition of an If/Else action. Is that the wrong way to use it?

I think it's the right approach, as it works. Thought you could use a macro group, but there's no option for Front Window

I've been tearing my hair out with this, trying to figure it out on my own as I've already asked so many questions, but I'm stumped. I'm sorry to have to ask another, but I've put in a lot of work to get this far, and I'm so close. Can anyone think why this is happening?

The green For Each action works every time, but the blue one only works when there are no files other than the matching one in the folder. I must be missing something.

Multiple files in the folder:

Only the matching file in the folder: