Move viewers or layouts into separate Taskbar groups

Requires Directory Opus 12.12.1 beta or above.


Overview:

Two script add-ins are provided:

  • One moves all standalone viewer windows into their own taskbar group, separate from all other Opus windows.

    TaskbarGroups

  • The other moves listers opened via layouts into a taskbar group specific to that layout.

    TaskbarGroups2

These demonstrate the SetTaskbarGroup methods added in Directory Opus 12.13. You can expand on the scripts to add more complex logic, if desired.

These scripts only work with Windows 7 and above, and only when the Taskbar is set to group windows together (the default).

Note that if you pin one of the alternative groups to the taskbar, clicking on it will still only launch Opus normally, which will probably (depending on your configuration) add a new window to the main group and not the one you clicked. Pinning is still useful if you want to fix the position of groups, rather than have them open at the end of the taskbar.


Download:

See How to use buttons and scripts from this forum for what to do with the two files. You only need to install the one(s) you want.


Script code:

The two .js.txt downlods above are reproduced here, for people browsing the forum for scripting techniques. If you just want to use the add-ins, you can ignore this part.

 
 

Viewer_taskbar_group.js.txt:

// Called by Directory Opus to initialize the script
function OnInit(initData)
{
	initData.name = "Viewer taskbar group";
	initData.version = "1.0";
	initData.copyright = "(c) 2019 Leo Davidson";
	initData.url = "https://resource.dopus.com/t/move-viewers-or-layouts-into-separate-taskbar-groups/31538";
	initData.desc = "Move viewer windows into a separate taskbar group";
	initData.default_enable = true;
	initData.min_version = "12.12.1";
}

// Called when an event takes place in the standalone viewer
function OnViewerEvent(viewerEventData)
{
	if (viewerEventData.event == "create")
	{
		viewerEventData.viewer.SetTaskbarGroup("viewer");
	}
}

 
 

Layout_taskbar_groups.js.txt:

// Called by Directory Opus to initialize the script
function OnInit(initData)
{
	initData.name = "Layout taskbar groups";
	initData.version = "1.0";
	initData.copyright = "(c) 2019 Leo Davidson";
	initData.url = "https://resource.dopus.com/t/move-viewers-or-layouts-into-separate-taskbar-groups/31538";
	initData.desc = "Move listers opened via layouts into their own taskbar groups";
	initData.default_enable = true;
	initData.min_version = "12.12.1";
}

// Called when a new Lister is opened
function OnOpenLister(openListerData)
{
	var lister = openListerData.lister;
	var layout = lister.layout;

	// We ignore the "openlisters" layout as those are just windows
	// re-opened after exiting and re-launching Opus (if configured that way),
	// and it doesn't make sense to treat them specially.
	if (layout != null && layout != "" && layout != "openlisters")
	{
		// The group name is truncated if longer than 103 characters
		// so this will group multiple layouts together if people have
		// ridiculously long layout names that are similar for the first
		// 103 characters. If that matters to you, you could hash the name
		// or something.
		lister.SetTaskbarGroup(layout);
	}
}

Brilliant this, thanks @Leo.