GP SoftwareTwitter
Opus FAQsManualCommandsObjects

Layout_UpdateOnClose_Handler: Automatically save non-default layouts when closing listers


#1

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.


Save all listers from within a script
Save positions of closed windows?
#2

Thanks for doing this

But, I cannot get it to work. The script and button are installed/added correctly, but I cannot figure out how to use the button itself or how it should actually work. Toggling it apparently does nothing on my system.

Does it rely on other settings in the DOpus config?


#3

Go into the scripts option in Prefs and post a screenshot of how you’ve got it configured. Also, enable the DEBUG option (set it to True), and open and close a saved lister layout. After doing so, post the /dopusdata\Logs\Script Output.txt file here and I’ll see whats happening.


#4

I was gearing up to learn what I had to do to write such a script…and to my sheer delight I find it written already.
@steje thank you very much sir.
I find it MUCH faster to learn to script if I start with something working and then view/edit.
Thanks once again.