Can anyone help me with a Macro that opens the Relink window in PT? After way too much time trying to actually find it, here's what the user must do: In an open Pro Tools session type OPTION/O (letter not number). That will open the workspace window. Do not use the keyboard shortcut to open the WORKSPACE window as it will not highlight the current open session which is the only way you can get the relink window. After typing OPTION/O, right click on the already highlighted session and a floating menu pops up with four choices. Click on Relink Offline and the desired relink window opens.
- Kitch Membery @Kitch2021-04-11 19:05:06.654Z2021-04-11 19:44:23.236Z
Hi @Mark_Mangini,
This should do the trick. :-)
const sessionPath = sf.ui.proTools.mainWindow.sessionPath; const sessionName = sessionPath.split('/').slice(-1)[0].split('.').slice(0, -1).join('.'); function openWorkspace() { const win = sf.ui.proTools.windows.whoseTitle.startsWith("Workspace: ").first; //If a workspace window is not open, open it. if (!win.exists) { sf.keyboard.press({ keys: "alt+o", }); } //Wait for Worksapce window win.elementWaitFor(); } function openRelinkWindow() { let win = sf.ui.proTools.windows.whoseTitle.startsWith("Workspace: ").first; let textGrid = win.tables.whoseTitle.is("TextGridView").allItems[1]; let rows = textGrid.children.whoseRole.is("AXRow"); let sessionRow = rows.filter(e => e.children.first.children.first.title.invalidate().value === sessionName)[0]; //Open right click popup menu let sessionRowMenu = sessionRow.childrenByRole("AXCell").first.popupMenuOpenFromElement({ isRightClick: true, }).popupMenu; //Right Click on Session File Name sessionRowMenu.popupMenuSelect({ isRightClick: true, menuPath: ['Relink Offline'] }); //Wait for window to appear sf.ui.proTools.windows.whoseTitle.is("Relink").first.elementWaitFor(); } function main() { //Activate Pro Tools Main Window sf.ui.proTools.appActivateMainWindow(); openWorkspace(); openRelinkWindow(); } main();
- MIn reply toMark_Mangini⬆:Mark Mangini @Mark_Mangini
You are a genius! Can you add a "Hide floating windows" Command at the end of the code? In my configuration, the Workspace window stays in the foreground even thought the Relink window is the active window, thus obscuring it. Like this:
- MMark Mangini @Mark_Mangini
Like this:
Kitch Membery @Kitch2021-04-11 19:51:54.413Z
Sure...
This should do the trick :-)
const sessionPath = sf.ui.proTools.mainWindow.sessionPath; const sessionName = sessionPath.split('/').slice(-1)[0].split('.').slice(0, -1).join('.'); function openWorkspace() { const win = sf.ui.proTools.windows.whoseTitle.startsWith("Workspace: ").first; //If a workspace window is not open, open it. if (!win.exists) { sf.keyboard.press({ keys: "alt+o", }); } //Wait for Worksapce window win.elementWaitFor(); } function openRelinkWindow() { let win = sf.ui.proTools.windows.whoseTitle.startsWith("Workspace: ").first; let textGrid = win.tables.whoseTitle.is("TextGridView").allItems[1]; let rows = textGrid.children.whoseRole.is("AXRow"); let sessionRow = rows.filter(e => e.children.first.children.first.title.invalidate().value === sessionName)[0]; //Open right click popup menu let sessionRowMenu = sessionRow.childrenByRole("AXCell").first.popupMenuOpenFromElement({ isRightClick: true, }).popupMenu; //Right Click on Session File Name sessionRowMenu.popupMenuSelect({ isRightClick: true, menuPath: ['Relink Offline'] }); //Wait for relink window to appear sf.ui.proTools.windows.whoseTitle.is("Relink").first.elementWaitFor(); //Close Workspace window win.windowClose(); //Wait for Workspace window to disappear win.elementWaitFor({waitType:'Disappear'}); } function main() { //Activate Pro Tools Main Window sf.ui.proTools.appActivateMainWindow(); openWorkspace(); openRelinkWindow(); } main();
- MIn reply toMark_Mangini⬆:Mark Mangini @Mark_Mangini
Thanks Kitch. That worked great! Much appreciated.
- RIn reply toMark_Mangini⬆:rick @rick
Hi Kitch, Do you have a script for only opening the workspace window without opening the Relink window?
Thanks:)Kitch Membery @Kitch2022-02-24 19:08:51.646Z
Hi @rick,
This should do the trick.
function openWorkspace() { const win = sf.ui.proTools.windows.whoseTitle.startsWith("Workspace: ").first; //If a workspace window is not open, open it. if (!win.exists) { sf.ui.proTools.menuClick({ menuPath: ["Window", "New Workspace", "Default"], }); } //Wait for Worksapce window win.elementWaitFor(); win.elementRaise(); } openWorkspace();
Rock on!
- Rrick @rick
Thank you Sir, very much appreciated!!
Kitch Membery @Kitch2022-02-25 00:23:41.436Z
You're welcome @rick :-)
- In reply toKitch⬆:AAndrew Sherman @Andrew_Sherman
Hi Kitch,
I've seen that you use functions like this in a few of your excellent scripts. What is the reason for it? As far as I can see one would be able to perform the command within the function without needing the function itself. However with my limited Javascript understanding I'm thinking maybe you're doing it like this as a sort of best practice so that the function could be called multiple times in a more complex script without having to spell it out each time. Is that correct?
Kitch Membery @Kitch2022-04-11 17:56:56.502Z
Hi @Andrew_Sherman,
Great question... And your assumption is correct. In the above function the the contents can be used without being inside the function.
It's good practice to create reusable functions. I have a library of them that I've created that I reuse all the time.
Here is an sudo-example of three functions being called from the "main" function.
function myFirstFunction(){ log('This text is being logged from "myFirstFunction"') } function mySecondFunction(){ log('This text is being logged from "mySecondFunction"') } function myThirdFunction(){ log('This text is being logged from "myThirdFunction"') } function main() { myFirstFunction(); mySecondFunction(); myThirdFunction(); myFirstFunction(); } main();
Rock on!
- AAndrew Sherman @Andrew_Sherman
Excellent, I can see that I'm going to use these a lot
Kitch Membery @Kitch2022-04-11 18:06:55.331Z
Awesome!!! :-)
- Rrandy matuszewski @randy_matuszewski
hey @Kitch, this doesn't seem to be working in the latest version of PT (2022.12) i wonder if the menu choices have changed since you wrote
click to show
- RIn reply toMark_Mangini⬆:randy matuszewski @randy_matuszewski
hey @Kitch, regretfully this appears broken again with the latest update. obviously, if you have time to patch this, it would be great but no sweat if you can't i'd hate to keep hounding you!
soundflow is giving an error in line 25 "could not open popup menu" thanks!
Kitch Membery @Kitch2023-01-27 19:01:41.951Z
Can you do a screen recording of the issue, that way I'll hopefully be able to see what is causing the problem. :-)
- In reply torandy_matuszewski⬆:MMark Mangini @Mark_Mangini
Yeah. Currently not working for me, either. Though I didn't change PT version. Still on 2022.10.0
Kitch Membery @Kitch2023-03-19 20:52:40.427Z
Hi Mark,
Can you take a screen recording so I can see where this script is failing. Hopefully that'll help me troubleshoot it. :-)
- MIn reply toMark_Mangini⬆:Mark Mangini @Mark_Mangini
Sure. Hang on a minute...
Kitch Membery @Kitch2023-03-19 21:39:30.589Z
I spoke too soon... Was able to recreate the quirky issue. I think I have a fix for it. Stand by. :-)
- MIn reply toMark_Mangini⬆:Mark Mangini @Mark_Mangini
I am discovering that it is session sensitive. I opened a new session with no audio and it worked fine. I opened a work session from the project I am on that has a lot of tracks and it doesn't work.
Kitch Membery @Kitch2023-03-19 21:42:59.215Z
Thanks Mark... Take note of the two sessions to test my new version with. (Still working on it) :-)
- In reply toMark_Mangini⬆:
Kitch Membery @Kitch2023-03-19 21:52:07.261Z
Quick question... If you perform this manually, Do you select the "Relink Offline" or "Relink" menu item from the ptx session right click?
I'm asking because for me, clicking the "Relink Offline" button does not open the "Relink" window but clicking the "Relink" menu opens the "Relink" window.
- In reply toMark_Mangini⬆:
Kitch Membery @Kitch2023-03-19 21:53:20.667Z
This is the menu I'm talking about.
Kitch Membery @Kitch2023-03-19 22:03:47.789Z
Try this @Mark_Mangini,
const relinkMenuOption = "Relink Offline"; const sessionPath = sf.ui.proTools.mainWindow.sessionPath; const sessionName = sessionPath.split('/').slice(-1)[0].split('.').slice(0, -1).join('.'); function openWorkspace() { const win = sf.ui.proTools.windows.whoseTitle.startsWith("Workspace: ").first; //If a workspace window is not open, open it. if (!win.exists) { sf.keyboard.press({ keys: "alt+o", }); } //Wait for Worksapce window win.elementWaitFor(); } function openRelinkWindow() { let win = sf.ui.proTools.windows.whoseTitle.startsWith("Workspace: ").first; win.elementRaise(); let textGrid = win.tables.whoseTitle.is("TextGridView").allItems[1]; let rows = textGrid.children.whoseRole.is("AXRow"); let sessionRow = rows.filter(e => e.children.first.children.first.title.invalidate().value === sessionName)[0]; //Open right click popup menu let sessionRowPopUpMenu = sessionRow.childrenByRole("AXCell").first.popupMenuOpenFromElement({ isRightClick: true, }).popupMenu; const relinkOflineMIPosition = sessionRowPopUpMenu.menuFetchAllItems().menuItems.filter(mi => mi.path[0] === relinkMenuOption)[0].element.position; //Get the current mouse position const oldMousePosition = sf.mouse.getPosition().position; //Click the menu item sf.mouse.setPosition({ position: relinkOflineMIPosition, }); sf.mouse.click({ position: relinkOflineMIPosition, }); //Return mouse position sf.mouse.setPosition({ position: oldMousePosition }); //Wait for relink window to appear sf.ui.proTools.windows.whoseTitle.is("Relink").first.elementWaitFor(); //Close Workspace window win.windowClose(); //Wait for Workspace window to disappear win.elementWaitFor({ waitType: 'Disappear' }); } function main() { //Activate Pro Tools Main Window sf.ui.proTools.appActivateMainWindow(); openWorkspace(); openRelinkWindow(); } main();
If that does not work, change the first line of the script to...
const relinkMenuOption = "Relink";
And try again.
- MIn reply toMark_Mangini⬆:Mark Mangini @Mark_Mangini
I don't even know where that menu is. I have only used the SoundFlow script.
Kitch Membery @Kitch2023-03-19 21:58:49.954Z
Its in the workspace menu when right clicking the PTX file in the Locations column. :-)
- MIn reply toMark_Mangini⬆:Mark Mangini @Mark_Mangini
I don't even know where that menu is. I have only used the SoundFlow script. This be as a consequence of having closed the ReLink window after opening a session, then wanting to re-open it.
- MIn reply toMark_Mangini⬆:Mark Mangini @Mark_Mangini
Most people don't know that, including myself. A truly hidden feature.
- MIn reply toMark_Mangini⬆:Mark Mangini @Mark_Mangini
This is a strange behavior. When I run the RELINK script, it fails and I get a Soundflow error message saying it couldn't run for 2000s. I then close the workspace window, and the relink window pops up.
Kitch Membery @Kitch2023-03-19 22:20:38.265Z
Hmmm The Relink window might have been open but behind the edit window. Can you try closing all instances of the "Workspace" and the "Relink" windows and try running the script?
- MIn reply toMark_Mangini⬆:Mark Mangini @Mark_Mangini
Nope, not the problem. But it appears to be related to window priorities. When I open a session and click the RELINK macro, it fails and I g
click to show - MIn reply toMark_Mangini⬆:Mark Mangini @Mark_Mangini
I can’t seem to make a JPEG screen recording. QT only makes .mov
Kitch Membery @Kitch2023-03-19 22:52:55.046Z
No worries, Mark,
I'm back at my Desktop computer now so I'll see if I can recreate the issue in PT 2022.10