View Modes Switcher

Overview

This simple script allows you to automate switching of selected view modes by specified actions. For example, it can be useful when viewing a large number of folders with images or videos.

How to use?

  1. Download View Modes Switcher.vbs.txt (2.7 KB)
  2. Open Preferences > Toolbars > Scripts and drag the downloaded file into the list.
  3. Select the new View Modes Switcher item and press Configure.

How to configure?

For example, you need switch to Thumbnails every time you open folder by double click, and switch back to Details when go to parent folder.

  1. choose from drop-down list dblclk as Action1 value
  2. choose from drop-down list parent as Action2 value
  3. choose from drop-down list Thumbnails as Mode1 value
  4. choose from drop-down list Details as Mode2 value
  5. double click on Switch1 and Switch2 to enable them
  6. press OK > OK

Now, double click on any folder to open it. View mode should change on Thumbnails. Double click on file display background to go to parent folder. View mode should change on Details.

Script Code:

The script inside the download above is reproduced here for reference:

Option Explicit

Dim ActionList, ModeList
Set ActionList = DOpus.NewVector(0, "none", "normal", "refresh", "parent", "root", "back", "forward", "dblclk")
Set ModeList = DOpus.NewVector(0, "none", "LargeIcons", "SmallIcons", "List", "Details", "Power", "Thumbnails", "Tiles")

Function OnInit(InitData)
   InitData.name = "View Modes Switcher"
   InitData.desc = "Automatic switching view modes."
   InitData.copyright = "(C) 2014 TVB"
   InitData.version = "0.3"
   InitData.default_enable = False
   InitData.config.Action1 = ActionList
   InitData.config.Action2 = ActionList
   InitData.config.Action3 = ActionList
   InitData.config.Action4 = ActionList
   InitData.config.Action5 = ActionList
   InitData.config.Action6 = ActionList
   InitData.config.Action7 = ActionList
   InitData.config.Mode1 = ModeList
   InitData.config.Mode2 = ModeList
   InitData.config.Mode3 = ModeList
   InitData.config.Mode4 = ModeList
   InitData.config.Mode5 = ModeList
   InitData.config.Mode6 = ModeList
   InitData.config.Mode7 = ModeList
   InitData.config.Switch1 = False
   InitData.config.Switch2 = False
   InitData.config.Switch3 = False
   InitData.config.Switch4 = False
   InitData.config.Switch5 = False
   InitData.config.Switch6 = False
   InitData.config.Switch7 = False
End Function

Function OnAfterFolderChange(AfterFolderChangeData)
   If AfterFolderChangeData.action = ActionList(Script.config.Action1 + 1) Then
      Call SetView(Script.config.Switch1, ModeList(Script.config.Mode1 + 1))
   ElseIf AfterFolderChangeData.action = ActionList(Script.config.Action2 + 1) Then
      Call SetView(Script.config.Switch2, ModeList(Script.config.Mode2 + 1))
   ElseIf AfterFolderChangeData.action = ActionList(Script.config.Action3 + 1) Then
      Call SetView(Script.config.Switch3, ModeList(Script.config.Mode3 + 1))
   ElseIf AfterFolderChangeData.action = ActionList(Script.config.Action4 + 1) Then
      Call SetView(Script.config.Switch4, ModeList(Script.config.Mode4 + 1))
   ElseIf AfterFolderChangeData.action = ActionList(Script.config.Action5 + 1) Then
      Call SetView(Script.config.Switch5, ModeList(Script.config.Mode5 + 1))
   ElseIf AfterFolderChangeData.action = ActionList(Script.config.Action6 + 1) Then
      Call SetView(Script.config.Switch6, ModeList(Script.config.Mode6 + 1))
   ElseIf AfterFolderChangeData.action = ActionList(Script.config.Action7 + 1) Then
      Call SetView(Script.config.Switch7, ModeList(Script.config.Mode7 + 1))
   End If
End Function

Sub SetView(Switch, Mode)
   If Switch Then
      Dim OpusCmd
      Set OpusCmd = DOpus.NewCommand
      If OpusCmd.IsSet("VIEW=" & Mode & "") = False Then
         OpusCmd.RunCommand("Set VIEW=" & Mode & "")
      End If
   End If
End Sub

Wouldn't that make every folder you open by double-click switch you into Thumbnails mode? Would you really want Opus to do that? (Or is this a script you turn on and off a lot, rather than one to keep on all the time?)

If you double-click into a folder full of pictures (double-click means you're switched into thumbnails mode), then into a subfolder full of pictures (double-click again, so still in thumbnails), then back up to the first folder full of pictures (parent means you're switched into details mode), you'll be switched in details mode but presumably still want to be in thumbnails. (If you want to view a folder as thumbnails when going down the tree, wouldn't you also want to view it in the same way when going up the tree?)

I don't understand why you would want to tie view mode changes to the navigation event (double-click, parent, etc.) and not to the actual folder paths or folder contents (which can both be done without scripts, using path formats and content type formats). Have I missed something?

It's just example. The script is always turned on, and Switch1 is almost always off.

In 95% cases my view mode is Details, but sometimes when I open a folder and change the view mode to thumbnails, and then double-click to back up a level, DOpus leaves the thumbnails instead details.

Ah OK, so the script is about resetting the view mode to normal/details when changing folders, after you have manually changed to some other view mode? That makes sense now.


April 2020 edit:

Some time after this script was written, Opus 12 added some new commands which can help here. For example Set FORMAT=!folder will reset the current tab to look how it would if you had just opened the current folder in a brand new tab, removing any view mode changes and so on which you had made.

If you find the script above useful, you might want to make it use that command instead of changing the view mode explicitly.

Of course, it depends on exactly what you want, and the way the script works already may be better for you as well.

Yes, Leo. All right.