Note: This script requires a minimum Opus version 12.2...
This script was written in response to a request described in the following discussion:
What does it do?:
This script handles the OnAfterFolderChange event so that when a user specified folder is opened the script will launch a saved lister layout associated with the folder. The association of the 'trigger' folder and the layout to load is specified in the scripts configuration options in Prefs in FolderLayoutList option.
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_AutoOpen_Handler.osp (3.21 KB)
Notes:
2016-11-22: v1.0.2 - Initial release...
After installing the script package, you should set the desired 'trigger' folder path and layout associations using the FolderLayoutList option. This can be done via the scripts Configuration dialog.
The format for the trigger folder path and layout association is: <folder_path> && <layout_name>. An entry like lib://My/projects/opus/scripting && my_Scripting will cause a layout named my_Scripting to be opened whenever the lib://My/projects/opus/scripting folder is opened...
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 layout_autoopen (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 tab, 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_AutoOpen</label>
<icon1>#layoutload</icon1>
<function type="normal">
<instruction>@toggle:if $lst:layout_autoopen</instruction>
<instruction />
<instruction>@ifset:$lst:layout_autoopen</instruction>
<instruction>@set lst:layout_autoopen</instruction>
<instruction />
<instruction>@ifset:else</instruction>
<instruction>@set lst:layout_autoopen=true</instruction>
</function>
</button>
...Feedback welcome.