Unfortunately, I haven't had a lot of luck with this.
The script that Edgemeal wrote works perfectly to close some kinds of windows, in some circumstances. It'll close the ReaScipt and Cycle Action Editor windows in every case I've tested, for example.
But in a couple of specific cases - murphy's law, the ones I'm interested in - it doesn't/can't seem to work on the window.
For example, the "Item: Auto trim/split items (remove silence):40315" dialog window seems to ignore the command. If I bind the 'force_foreground_close' script to a shortcut key, then I see the shortcut key get interpreted as input for the Threshold field. If I have the lua script be the first action of the next cycle step, then when I press the shortcut for the cycle action, I get something similar happening.
If I use the lua script in a cycle action, so that immediately after launching a tool the script runs (at the end of the current step, before the next step). Obviously a daft case, but an interesting test. I'd expect that to expect to bring up the window and then close it right away. That does work for all the following windows:
Item: Dynamic split items...:40760
Script: cool_MK Slicer.lua _RS9046b9e404c280177dd4309db8cca88a6fac66ef
Script: LKC - Variator - GUI.lua _RSc473f1c14675e8560d5daf4bcce10a4eeb2ba803
But doesn't work for Item: Auto trim/split items (remove silence)... :40315.
The slightly weirder thing is if I then move the lua script calls in the cycle action so that they trigger at the start of the next step, the script then silently fails to close them. I'm not moving the mouse, clicking anywhere or doing anything other than inputting the cycle action shortcut to move to the next step (i.e. I don't see the window lose focus).
Using the script shortcut key while the windows are focused (simulating the end of that cycle step) also fails to close them.
In those cases, the next window will fail to open, because all the windows I've listed are expecting to open when the main window and an item is in focus. (In cases where I set the focus to the arrange view with something like "SWS/BR: Focus arrange:_BR_FOCUS_ARRANGE_WND", trying the next step of the cycle fails, even though an item is selected - but that's by the by for now, given the other problems).
I did also play around a bit with "SWS/S&M: Focus main window (close others):_S&M_WNMAIN_HIDE_OTHERS" - which I think I must have overlooked before. I got some inconsistent results with that too. For example, it closes "Dynamic split items" but not "Auto trim/split". And even though a valid item remains selected, pushing focus to the main window doesn't seem to give the other tools the state they need.
Hitting the ESC key does close them all... so Philbo King's post isn't a bad shout. But...
Now I'm stuck trying to work out how to simulate an ESC keypress as a step in the cycle action. There doesn't seem to be an action for it. I don't think I can use the CONSOLE option in the cycle action editor as I can't see a way to simulate keypresses in the sws console. I'd guess a reascript written in python could... not sure about lua. But I'd have to dig thorough the python/lua docs to find info on I/O stuff. I usually only use python to do basic batch scripting on files, rename/remove, etc. I don't know lua at all, or either in the context of reascript.
I did also play around a bit with "SWS/S&M: Focus main window (close others):_S&M_WNMAIN_HIDE_OTHERS" - which I think I must have overlooked before. I got some inconsistent results with that too. For example, it closes "Dynamic split items" but not "Auto trim/split".
This is a version of the cycle action, with separate window closing and opening:
Code:
[Main_Cyclactions]
; Do not tweak by hand! Use the Cycle Action editor instead
Action1="Custom: XaWi: Cycle: AutoTrim & Split Tools|_RS3cde775403ae0d3355c9f50c1280e2ea73dd46f2|_BR_FOCUS_ARRANGE_WND|!|40760|!|_RS3cde775403ae0d3355c9f50c1280e2ea73dd46f2|_BR_FOCUS_ARRANGE_WND|!|40315|!|_RS3cde775403ae0d3355c9f50c1280e2ea73dd46f2|_BR_FOCUS_ARRANGE_WND|!|_RS9046b9e404c280177dd4309db8cca88a6fac66ef|!|_RS3cde775403ae0d3355c9f50c1280e2ea73dd46f2|_BR_FOCUS_ARRANGE_WND|!|_RSc473f1c14675e8560d5daf4bcce10a4eeb2ba803|"
Nb_Actions=1
Version=3