Note: This script requires a minimum Opus version 12.2...
This script was written in response to a request described in the following discussion:
Save positions of closed windows?
What does it do?:
This script handles the OnCloseLister event so that when a lister is closed the script will look to see if it was part of a user defined lister layout. By default, the 'default lister' is excluded from this behavior - since Opus has long had it's own option for automatically updating the default lister. However, handling of the 'default' lister can be enabled in the scripts configuration options in Prefs.
How to install and use it?:
The script is provided here as an Opus Script Package... which in turn is actually a zip file with a VBScript packaged inside. It can be installed by either manually copying the OSP file to the /scripts folder, or via drag-and-drop into the Preferences / Toolbars / Scripts page.
Download: Layout_UpdateOnClose_Handler.osp (3.27 KB)
Notes:
2016-11-22: v1.0.2 - Initial release...
After installing the script package, you can set the ExcludeLayoutList option to EXCLUDE any saved lister layouts you do NOT want to update when it's listers are closed. You can also enable the automatic update of the 'default lister' layout by setting the IncludeDefaultLayout to True. If this is enabled, there are also additional SetAsDefaultForce and SetAsDefaultQuiet options to pass through the related options to the Prefs SETDEFAULTLISTER command. This can all be done via the scripts Configuration dialog.
NOTE: about multi-lister layouts... With this initial release, only single lister layouts are supported. There is no way to interrogate Opus for details about a lister layout in order to automatically determine whether or not the script should save all listers or just the one being closed. I'm more than happy to listen to ideas on how this could be improved (prompts, use of additional variables, etc).
In addition to the qualifier keys that can be set to enable/disable the scripts execution (qualifier keys require the Always_On option to be set to True), script execution can also be enabled by the use of an Opus environment variable called (requires the Always_On option to be set to False).
Here is a sample toolbar button that toggles the lister scoped variable (the script supports lister or global scoped variables) which you can copy and paste directly to your toolbar:
<?xml version="1.0"?>
<button backcol="none" display="both" label_pos="right" textcol="none">
<label>Layout_UpdateOnClose</label>
<icon1>#savedlayoutsedit</icon1>
<function type="normal">
<instruction>@toggle:if $lst:layout_updateonclose</instruction>
<instruction />
<instruction>@ifset:$lst:layout_updateonclose</instruction>
<instruction>@set lst:layout_updateonclose</instruction>
<instruction />
<instruction>@ifset:else</instruction>
<instruction>@set lst:layout_updateonclose=true</instruction>
</function>
</button>
...Feedback welcome.