GP SoftwareTwitter
Opus FAQsManualCommandsObjects

Layout_AutoOpen_Handler: Open a saved lister layout when opening trigger folder


#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:

Start with DOpus scripting

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.


Start with DOpus scripting
#2

I am new to DO. I really like this script you created, however I am lost a little.
What does the line below refer to exactly? Is this an existing OS folder?
If so, how would I go about adding something like this d:\myfolder\thisfolder ?


#3

lib://My/projects/opus/scripting is Opus’s way of letting you type paths to a Windows library (called “My” in this case).

There isn’t a “My” library by default, but if you type something like lib://Documents into the path field in Opus, you’ll go to your Documents library.

Libraries work in File Explorer as well, but the lib://… style paths only work in Opus.

The && my_Scripting part of the example is specific to this script add-in, and explained in the root post. my_Scripting is the name of a lister layout that steje must have saved.

If you want to set the script to open your CatsAndDogs layout when you go into d:\myfolder\thisfolder then I think you would use this in the configuration:


#4

Thanks Leo. Will give it a try.


#5

One more thing, if I want this for multiple folders, do I add the script each time and just update the path?


#6

No it looks like you can add as many paths as you want, one on each line, e.g.

d:\myfolder\thisfolder && CatsAndDogs
e:\anotherfolder\thatfolder && BirdsAndFrogs