How to make 'view presets' for Clip List menu and submenus
Hello SF community! And a huge THANK YOU to @Kitch for hosting a great webinar today :)
I use the Clip List functions a lot, and am wondering if one can trigger various 'presets' to toggle certain views and functions:

Intention here is to trigger/cycle through a combination of views, and also use as part of a larger macro.
Am still new to JS scripting, but wish to learn more!
Thanks so much for the help,
Curtis
- Kitch Membery @Kitch2022-11-09 22:22:11.452Z
Thanks for joining us, Curtis, I'll take a look at this when I have a moment :-)
Rock on!
- In reply toCurtis_Macdonald⬆:Kitch Membery @Kitch2022-11-09 23:00:15.642Z
Something like this should do the trick. :-)
//For each View Setting set the menuPath as well as the targetValue to either "Enable","Disable","Toggle" or "Ignore" //Assigning "Ignore" to a view setting's target path will leave the menu item in its current state. const viewSettings = [ { menuPath: ["Show", "Audio"], targetValue: "Toggle" }, { menuPath: ["Show", "MIDI"], targetValue: "Enable" }, { menuPath: ["Show", "Video"], targetValue: "Disable" }, { menuPath: ["Show", "Groups"], targetValue: "Ignore" }, { menuPath: ["Show", "Auto-Created"], targetValue: "Toggle" }, { menuPath: ["Show", "Timebase"], targetValue: "Toggle" }, { menuPath: ["Show", "Color"], targetValue: "Toggle" }, { menuPath: ["Show", "Processing State"], targetValue: "Toggle" }, { menuPath: ["Show", "File Type"], targetValue: "Toggle" }, { menuPath: ["Show", "File Name"], targetValue: "Toggle" }, { menuPath: ["Show", "Disk Name"], targetValue: "Toggle" }, { menuPath: ["Show", "Full Path"], targetValue: "Toggle" }, { menuPath: ["Show", "Channel Name"], targetValue: "Toggle" }, { menuPath: ["Show", "Scene and Take"], targetValue: "Toggle" }, ]; function setClipListViews(viewSettings) { sf.ui.proTools.appActivateMainWindow(); const isClipListVisible = sf.ui.proTools.getMenuItem("View", "Other Displays", "Clip List").isMenuChecked; sf.ui.proTools.menuClick({ menuPath: ["View", "Other Displays", "Clip List"], targetValue: "Enable" }); viewSettings.forEach(view => { const { menuPath, targetValue } = view if (targetValue !== "Ignore") { sf.ui.proTools.mainWindow.popupButtons.first.popupMenuSelect({ menuPath, // @ts-ignore targetValue, }); } }); if (!isClipListVisible) { sf.ui.proTools.menuClick({ menuPath: ["View", "Other Displays", "Clip List"], targetValue: "Disable", }); } } setClipListViews(viewSettings);
Curtis Macdonald @Curtis_Macdonald
Thank you so much Kitch!!
Kitch Membery @Kitch2022-11-09 23:50:33.719Z
My pleasure, Curtis.
Let me know if you have any questions about the script. :-)
Curtis Macdonald @Curtis_Macdonald
Playing around with this has been really insightful, thanks again Kitch!
One additional question: How does one access the right-click contextual menu in the Clip list? I'm trying to use Christian's snippet from this post: Reveal In FInder ( right click on a clip in clip list) #post-2
var selectedClipRows = sf.ui.proTools.mainWindow.clipListView.getElements('AXSelectedRows'); selectedClipRows[0].children.allItems[1].children.first.popupMenuSelect({ isRightClick: true, menuPath: ['Reveal in Finder'], });
But it's not working for me and I'm not exactly sure why just yet.
Kitch Membery @Kitch2022-11-10 18:45:24.002Z
Hmmm I just tested it on my system and it works.
How are you running the script?
Could you try activating Pro Tool's window first?
sf.ui.proTools.appActivateMainWindow(); const selectedClipRows = sf.ui.proTools.mainWindow.clipListView.getElements('AXSelectedRows'); selectedClipRows[0].children.allItems[1].children.first.popupMenuSelect({ isRightClick: true, menuPath: ['Reveal in Finder'], });
Let me know if that works for you?
If not maybe try restarting SoundFlow just in case. :-)
Curtis Macdonald @Curtis_Macdonald
It's super weird cause it was working fine for me for a while, and then it suddenly stopped... Added the activate window, restarted SF and PT a few times, error on line 5 still persists "Could not open Pop Up Window". Will keep trying!
Kitch Membery @Kitch2022-11-11 01:07:38.154Z
Pro Tool's main window may need invalidating with this script.
Give this a go:
sf.ui.proTools.appActivateMainWindow(); sf.ui.proTools.mainWindow.invalidate(); const selectedClipRows = sf.ui.proTools.mainWindow.clipListView.getElements('AXSelectedRows'); selectedClipRows[0].children.allItems[1].children.first.popupMenuSelect({ isRightClick: true, menuPath: ['Reveal in Finder'], });
Curtis Macdonald @Curtis_Macdonald
That did it! You're such a wizard, Kitch!
How does one know when a window needs to be 'invalidated'?
Curtis Macdonald @Curtis_Macdonald
Aaand it just stopped working again, haha! Got it back working by removing:
sf.ui.proTools.mainWindow.invalidate();
I suppose it may need to validated/invalidated at times. Worry about it later for now I suppose. Thanks again Kitch!
Kitch Membery @Kitch2022-11-11 02:16:14.608Z
I can reproduce the issue here... I'll take a look when I have a moment.
- In reply toCurtis_Macdonald⬆:
Kitch Membery @Kitch2022-11-11 02:25:56.149Z
You may not have a row selected. Try this :-)
sf.ui.proTools.appActivateMainWindow(); const selectedClipRows = sf.ui.proTools.mainWindow.clipListView.childrenByRole('AXRow'); selectedClipRows[0].children.allItems[1].children.first.popupMenuSelect({ isRightClick: true, menuPath: ['Reveal in Finder'], });
Curtis Macdonald @Curtis_Macdonald
Hmm, the script is executing properly now—feels super solid, but it's opening the wrong clip in finder. Looks like it's revealing whatever is the topmost clip in the clips list, despite what is selected/highlighted. For instance, if a clip is selected and highlighted at the bottom of the clip list, the script currently ignores that and selects whatever the first clip is.
Kitch Membery @Kitch2022-11-11 21:36:00.462Z
My bad...
I thought you were trying to select the first row. Not the selected row.
sf.ui.proTools.appActivateMainWindow(); const clipsList = sf.ui.proTools.mainWindow.clipListView; const rows = clipsList.children.whoseRole.is("AXRow"); const selectedClipRows = rows.filter(row => { return row.childrenByRole("AXCell").allItems[1].childrenByRole("AXStaticText").first.value.invalidate().value.startsWith("Selected. ") }); selectedClipRows[0].children.allItems[1].children.first.popupMenuSelect({ isRightClick: true, menuPath: ['Reveal in Finder'], });
Try using this method. :-)
Curtis Macdonald @Curtis_Macdonald
Thank you Kitch! It's so helpful seeing all these changes as I slowly learn JS!
This worked for the first few times, but started to return errors only after a few attempts.
I've modified this script that has been working reliably, but I know it's not an ideal solution given how many keystrokes are used: Reveal In FInder ( right click on a clip in clip list) #post-10Kitch Membery @Kitch2022-11-14 19:00:04.584Z
No worries Curtis,
Can you share the full script you are working on so I can take a look?
Also what are the errors you are seeing after running the script a few times?
It might also be helpful if you could do a screen recording of when it fails.
Rock on!
Curtis Macdonald @Curtis_Macdonald
Of course! I'll screen capture the error behavior when I have a moment. In the meantime here's the script I've been working with, that seems to be working well for my purposes so far:
sf.ui.proTools.appActivate(); // clear clip list search for good measure sf.keyboard.press({ keys: "cmd+shift+d", }); // Open Rename, copy Filename and close Rename sf.ui.proTools.menuClick({ menuPath: ["Clip","Rename..."], }); sf.ui.proTools.menuClick({ menuPath: ["Edit","Copy"], }); sf.ui.proTools.focusedWindow.buttons.whoseTitle.is('OK').first.mouseClickElement(); // Wait sf.wait({ intervalMs: 500, }); // Open Find from Clips List, Paste Filename and close Find sf.keyboard.press({ keys: "cmd+shift+f", }); sf.ui.proTools.windows.whoseTitle.is('Find Clips').first.elementWaitFor(); sf.ui.proTools.menuClick({ menuPath: ["Edit","Paste"], }); sf.ui.proTools.windows.whoseTitle.is('Find Clips').first.buttons.whoseTitle.is('OK').first.mouseClickElement(); // Go to the beginning of the clip, select it to make it appear in Clips View sf.keyboard.press({ keys: "l", }); sf.keyboard.press({ keys: "ctrl+shift+tab", }); sf.wait({ intervalMs: 1000, }); // Click first Row in Clip List, Reveal in Finder (from Kitch) sf.ui.proTools.appActivateMainWindow(); const selectedClipRows = sf.ui.proTools.mainWindow.clipListView.childrenByRole('AXRow'); selectedClipRows[0].children.allItems[1].children.first.popupMenuSelect({ isRightClick: true, menuPath: ['Reveal in Finder'], }); // Wait for finder sf.wait({ intervalMs: 1000, }); // Get Info on Clip sf.keyboard.press({ keys: "cmd+i", });