Automatic trigger when new project is opened in Pro Tools

I am looking for a way to automatically trigger a macro when a new project is opened in my audio application "Pro Tools". They call it Session but the idea is the same.

The goal is to delete a certain KM variable that I use within a project but does not apply to other projects and must therefore be deleted. And be filled up again in the new project.

I can use the trigger "when focussed window" changes. Then it will trigger awfully often but that's ok. In combination with an IfThenElse that checks if the main window is not available anymore. If that is the caseI can then delete this variable.

This works well as long as the user closes the project and opens a new one.

BUT, if the user opens a new project (session) through the Open Recent.... menu, ie closing the current project and opening the new one in one flow, then this main window will remain, ie it just opens with the new data. Meaning my intended goal is not reached.

Does anyone has an idea how to tackle this?

This is the current macro that only works when a session is closed and then a new session is opened. But fails if the user uses the Open Recent menu.

I wonder if you might use a dictionary called, for example, "Sessions", and then set or update a key for each "session" whenever the front window changes. You would then be able to maintain changes to values for each session independently, no matter how many sessions were open.

To break that down a little:

  1. Create a macro that is triggered when the focused window changes (as you have been doing).
  2. The macro would contain a Set Dictionary action to set the value of dictionary "Sessions", key "session %WindowName%1%" to your "certain KM value". :slight_smile:

Each "session" key there is named after the current front window.

If this seems like a remotely useful idea, in order to proceed, you would need a better understanding than I have about KM's implementation of dictionaries. :confused:

I thought about this but I rejected it as this database will be overcrowded in some time. But maybe I could delete it when I I boot or shut down the computer.
I will reconsider it what this means. Thanks.

I am well known with dictionary's so this will be fine. :slight_smile:

1 Like

It sounds like you simply want a macro to trigger whenever the current project name changes. I've tested this in Logic Pro so perhaps it will work in PT too.

Trigger on Project Title Change.kmmacros (22 KB)

Macro screenshot

Yes, this is an option I considered. Although I have some issues it might still be the best option.

When re-opening the current session without saving your changes, like when Revert to Saved,it will fail.

And when you rename the session it will unnecessary delete my variable. So not elegant but we we can live with.