Cycle through Layouts

David - that is the first line on lxp's button. Can you explain what you thing the problem is?

That line was added to lxp's button by Directory Opus.
Somehow the button was set to Script Function and then was changed to Standard Function.
When the button was changed, Directory Opus added the line @script JScript.

Try removing that line.
Does it work then ?

Thanks - I don't know much about scripting. The JScript line looks like it was added when I switched back and forth between Standard and Script trying to fix it.

Using freshly pasted versions of lxp's Cycle button and the 'test' button he attached above, and confirming that neither have the "@script JScript" included in the code, I still get nothing when clicking either button.

I'm beginning to think that lxp is right and there is something wrong with my Windows installation. If anyone has any idea how to check or where to start I'd appreciate it.

Ensure that the script has properly installed.

Settings > Scripts

SaveLayoutsAsVars should be in the list.

I appreciate all of the attempts to help with this! The script is installed in the right location and status shows 'OK' in the script management window.

Don't worry about the script if the SysInfo test button doesn't work.

What you could try to repair:

  • Install all Windows updates
  • Backup/uninstall/install Opus. Try the button before restoring the backup
  • Run Windows System File Checker (SFC): Execute sfc /scannow from a command line.

If this doesn't fix it it might be less effort to wipe the system and start with a fresh Windows installation.

I figured out what the issue was related to the script, and the Cycle through Layouts works now! Posting here in case someone else runs into this in the future. I was reviewing my Layouts and found two layouts that showed they had zero listers! I think this is an artifact of a prior computer that got carried forwarded. Once I deleted both of those it works perfectly! This is really useful. Thank you lxp!

Unfortunately, I still can't figure out why the "Hi" does pop up in the test script.

1 Like

Click the version info with your mouse.
The script log then shows "Hi" .

Glad you don't have to start over with a new Windows installation ! :grinning:

1 Like

This is such a great script, re-thank you very much :sparkling_heart: @lxp I've been using it daily ever since and it's has been a huge time saver in my workflows.

I was wondering, is it correct that the script cycles through all the saved lister layouts?

For example:

Let's say I would like to have specific lister layout that auto launches when I connect an external USB drive on occasion. What I'm trying to achieve in a bit more detail:

I wouldn't want that lister layout to be included in saved layouts cycle list when the drive is not connected, as that would clutter cycle list I use very often too much. Hence why I would like to exclude these layouts from the cycle list.

I did find how to hide/grey out a specific saved lister and still be present in the saved lister layouts list so they can be activated when needed or when the drive gets connected again...

However this doesn't seem to exclude the hidden lister from the cycle button list?

I didn't even know layouts could be hidden :slight_smile:

Detecting hidden layouts seems to be straightforward. Try this new version:

EventSaveLayoutsAsVars.js.txt (2025-10-03)

Thank you! From my testing the updated version does hide the hidden Layout ('Time Storms') in the Menu bar > Settings > Lister Layouts > Saved Layouts list.

Though using the command button to cycle through the (unhidden) Saved Layouts still triggers the hidden Layout at some point when doing a full list cycle.

Please check the first lines of the .oll files in /dopusdata\Layouts.

Do the lister_layout tags contain anything other than:

<lister_layout flags="192">

or

<lister_layout flags="224">

Yes they do,

The visible/unhidden Layouts show:

<lister_layout flags="193">

The hidden Layout ('Time Storms', in my case, as in the screenshot above):

<lister_layout flags="225">

I see. Let's replace

if (xmlText.indexOf('<lister_layout flags="224">') > 0) continue;  // Layout is hidden

with

if (xmlText.indexOf('<lister_layout flags="22') > 0) continue;  // Layout is hidden

Admittedly, a bit pragmatic :wink:

1 Like

But very effective! :grinning_face_with_smiling_eyes:

With this change the hidden Layout is now indeed excluded from the full list cycle and reincluded in the button cycle when under 'Edit Layout' I uncheck 'hide this layout from layout list'

Also tried with other saved Layouts from my list and it all seems to work beautifully!

Thank you very much @lxp for your efforts ro get this working and for sharing your magic :magic_wand: :man_mage:

@lxp

I've been using your excellent “Cycle through Layouts” script daily ever since :ok_hand:.

I have the button placed on my toolbar (with non-full width spacers on each side) and the button label set to the right of the icon. Currently as the name changes and the dynamic label becomes longer or shorter, the icon shifts position, which is visually distracting.

Is there a way to keep the icon anchored at a fixed position on the left side of the button while allowing the label text to change dynamically to the right?

I've tried various things but without much luck so far. Any idea how this can be overcome?

 
 
And on another note…

Would it be possible to add a context menu to the “Cycle Layouts” button on right-click, if feasible?

The menu could display a clickable list of all Saved Layouts in the carousel cycle, similar to how Saved Listers can be selected from Settings → Lister Layouts or the Lister drop-down menu on the Directory Opus toolbar.

This would allow jumping directly to a specific Saved Layout when needed, instead of cycling through layouts one at a time. The current cycling behaviour would remain useful for adjacent layouts, while the context menu would provide a faster way to make larger jumps.

I am not sure I understand the problem. Isn't the icon fixed if the label is shown on the right side?

Some commands do support context menus (like Go HOMEDIR) but most do not. This might be trick dynamic toolbar buttons could learn, seems like a useful feature.

Instead of a context menu you could turn the button into a menu button and show the available layouts using Prefs LAYOUTLIST.

XML
<?xml version="1.0"?>
<button backcol="none" display="both" label_pos="right" textcol="none" type="menu_button">
	<label>%1</label>
	<tip>=Val(&quot;$lst:nextLayout&quot;) + &quot;\n&quot; + Val(&quot;$lst:prevLayout&quot;) + &quot; (Shift)&quot;</tip>
	<icon1>#newbuttonmenu</icon1>
	<function type="normal">
		<instruction>@label:cL=Val(&quot;$lst:currLayout&quot;);Format(original_label, (cL==&quot;&quot; ? &quot;&lt;none&gt;&quot; : cL))</instruction>
		<instruction>Prefs LAYOUT=&quot;{=KeyDown(&quot;shift&quot;) ? Val(&quot;$lst:prevLayout&quot;) : Val(&quot;$lst:nextLayout&quot;)=}&quot;</instruction>
		<instruction />
		<instruction>// https://resource.dopus.com/t/cycle-through-layouts/51223</instruction>
	</function>
	<button backcol="none" display="both" label_pos="right" textcol="none">
		<label>Saved Layouts</label>
		<icon1>#newcommand</icon1>
		<function type="normal">
			<instruction>Prefs LAYOUTLIST SHOWICONS</instruction>
		</function>
	</button>
</button>
1 Like

Yes exactly, resulting in shifting of the icon when the dynamic label changes, which I've tried to illustrate more clearly below. (please note the red guidelines as visual reference points, aligned to the Filter folder icon and the letter 'r' of the word 'Filter' above)

 
Currently (with button set to show label right)
 

 
 
Desired (with button set to show label right, but with icon position anchored and dynamic label sizing from there)
 

Thank you very much @lxp! Your help and the solution regarding the menu button, along with the accompanying XML button code, works perfectly. It exactly adds the functionality I was looking for! I really appreciate your time and guidance. :sparkles:

Icon shifting (as in illustrated with the screenshots posted here above) is still/also occurring with the menu button. Perhaps @Leo or @Jon can chime in on how an icon can be locked or kept in a fixed position in a case like this. Any insights would be great.