Plugin windows masking UI elements
Hi everyone,
I'm writing a script that requires opening insert and audiosuite plugins, aswell as duplicating playlists.
I was wondering if there is a way to ensure the location of the plugin window, or a way to prevent the selected track name/menu to be covered.
For now, I'm closing plugin and audiosuite windows, but if there is a more elegant way, I'd love it!
All of this is within a for loop, I'd like the audiosuite to close at the last iteration, not at every iteration. I know how to do it, but can't because of the randomness of the plugin window location.
Any ideas?
Thank you lots!
T.
- Chris Shaw @Chris_Shaw2024-06-20 20:45:22.120Z
The quick and dirty way would be to use ctrl-opt-cmd-w (via
sf.keysbaord.press()
followed by a short wait to hide all floating windows. As long as no other windows are opened afterward, hitting the same key combo would restore the hidden windows.
The more robust way would be to create a window configuration, close all floating windows withsf.ui.proTools.floatingWindows.forEach(win =>win.windowClose())
then after doing what you need to do recall and delete the window configuration.
There should be some scripts on the forum for creating, recalling, and deleting window configs- TThomas Gloor @Thomas_Gloor
Thank you @Chris_Shaw
I basically stored the windows I need in variables and use windowClose() to close them.
I think I mis-explained. Actually it’s more about ensuring the track pop up menu is always accessible without closing all windows.
Chris Shaw @Chris_Shaw2024-06-23 04:05:15.404Z2024-06-24 18:59:03.476Z
Here's a function that will move all windows except Mix and Edit to the bottom of the edit window (The top of the windows will cover the clip fx tabs). The original positions will be stored in
globalState
. When run again the windows will be moved to their original positions:function moveAndRestoreNonEditWindowPositions() { sf.ui.proTools.appActivate(); // If globalState.floatingWinsOriginal is undefined move windows // store orig positions in global state then move them to the bottom of Edit window if (!globalState.floatingWinsOriginal) { globalState.floatingWinsOriginal = {} const floatingWindows = sf.ui.proTools.windows.filter(w => !w.title.invalidate().value.startsWith("Edit") && !w.title.invalidate().value.startsWith("Mix")) // Get edit window y and height const { y: editWindowY, h: editWindowH } = sf.ui.proTools.mainWindow.frame; // Store window elements in global state //Create unique key for each window to accommodate duplicates let count = 0 floatingWindows.forEach(win => { let { x, y, } = win.frame globalState.floatingWinsOriginal[`k${count}`] = { winTitle: win.title.value, x, y, } // move window to bottom of Edit window win.windowMove({ position: { x, y: editWindowY + editWindowH - 10 } }) count++ }) } else { // globalState.floatingWinsOriginal exists. // Return windows to original position // and delete globalState.floatingWinsOriginal const floatingWinsOriginal = globalState.floatingWinsOriginal const windows = sf.ui.proTools.windows.invalidate().allItems; Object.keys(floatingWinsOriginal).forEach(key => { let windowName = floatingWinsOriginal[key].winTitle; // filter for duplicate window names // select window that has same x position as current stored window let windowToMove = windows.whoseTitle.is(windowName) .filter(win => win.frame.x == floatingWinsOriginal[key].x )[0] if (windowToMove) { windowToMove.windowMove({ position: { x: floatingWinsOriginal[key].x, y: floatingWinsOriginal[key].y } }) } }) delete globalState.floatingWinsOriginal } } moveAndRestoreNonEditWindowPositions()
- TThomas Gloor @Thomas_Gloor
It works great! Except for one thing. If there is 2 instances of the same plugin, the script doesn't put one of them back in it's place!
Chris Shaw @Chris_Shaw2024-06-24 18:20:00.930Z
I re-edited the script above to accommodate duplicate plug-in and AS windows.
The only time this won't work is if two windows with the same name have the exact same x coordinates.
- TIn reply toThomas_Gloor⬆:Thomas Gloor @Thomas_Gloor
Oh wow!
Thank you so much @Chris_Shaw
I’ll try it later.Would there be a way to including in script, so that every time a window opens, it checks if it is in the way and then move it?
I assume something like storing the position of the opened window in a variable, and an if statement that triggers or not the movewindow script?