I use the following script to generate a custom titlebar:
function OnInit(initData)
{
initData.name = "Custom Title Bar";
initData.version = "1.3";
initData.copyright = "(c) 2019 cwfrizzell";
initData.url = "https://resource.dopus.com/t/set-listertitle-to-include-file-display-view-mode/31991";
initData.desc = "This script enables users to customize the Title Bar to reflect user-selected DOpus data.";
initData.default_enable = true;
initData.min_version = "12.0";
//Get User and Machine names
var objWSH = new ActiveXObject("WScript.Shell");
var objEnv = objWSH.Environment("Process");
DOpus.vars.set("ListerTitleUser",objEnv("USERNAME"));
DOpus.vars.set("ListerTitleDomain",objEnv("USERDOMAIN"));
var objcfg = initData.config;
objcfg.Debug = true;
}
//Global Variables
var cmd = DOpus.create.command;
var version = DOpus.version.product;
var tab, tabs, dual, viewMode, activeDisplay, globalFilterFlag, quickFilterSet, quickFilterFlag, title;
var hideHiddenFlag, hideSystemFlag;
var filterSet = DOpus.filters.enable;
function OnOpenLister(OpenListerData)
{
tab = OpenListerData.lister.activetab;
cmd.SetSourceTab(tab);
tabs = tab.right;
//Determine layout type and identify active display on Lister open
dual = tab.source;
if (dual == "1" && tabs == true)//check for dual vertical, active right display
{
activeDisplay = "Right"
} else if (dual == "1" && tabs == false)//check for dual vertical, active left display
{
activeDisplay = "Left"
} else if (dual == "2" && tabs == true)//check for dual horizontal, active bottom display
{
activeDisplay = "Bottom"
} else if (dual == "2" && tabs == false)//check for dual horizontal, active top display
{
activeDisplay = "Top"
} else//if not dual vertical or horizontal, must be a single display
{
activeDisplay = "Display"
}
//Determine view mode status on Lister open
viewMode = tab.format.view;
viewMode = viewMode.substring(0,1).toUpperCase() + viewMode.substring(1);
//Determine global filter status on Lister open
if (filterSet== true)
{
globalFilterFlag = "ON"
} else
{
globalFilterFlag = "OFF"
}
//Determine quickfilter status on Lister open
quickFilterSet = tab.quickfilter.filter;
if (quickFilterSet === '')
{
quickFilterFlag = "OFF"
} else
{
quickFilterFlag = "[ " + quickFilterSet + " ]"
}
//Determine if hide hidden files set to true
if (cmd.IsSet("GLOBALHIDEHIDDEN=Toggle"))
{
hideHiddenFlag = "ON"
} else
{
hideHiddenFlag = "OFF"
}
//Determine if hide system files set to true
if (cmd.IsSet("HIDESYSTEMFILES=Toggle"))
{
hideSystemFlag = "OFF"
} else
{
hideSystemFlag = "ON"
}
//Build Lister Title
title = "notoggle:Directory Opus " + version + " Pro (64-bit) | LAYOUT: %L | STYLE: %S | ACTIVE: " + activeDisplay + " | VIEW: " + viewMode + " | FILTERS: Q - " + quickFilterFlag + " G - " + globalFilterFlag + " H - " + hideHiddenFlag + " S - " + hideSystemFlag
var id = tab.path.def_value;
if (tab.path.test_root == 0) //Check if at root drive
{
if (id.substr(id.length - 1) == "\\")
{
title = title + " | FOLDER: %R\\"; //Ensures root drive displayed properly
} else
{
title = title + " | FOLDER: %R";
}
} else
{
title = title + " | FOLDER: %R\\...\\%N";
}
DOpus.Output(title);
cmd.RunCommand('Set LISTERTITLE="' + title + '"');
}
function UpdateTitleFilter(ScriptCommandData)
{
//update title after quickfilter applied
cmdname = UpdateTitleFilter;
UpdateTitle(lister);
}
function UpdateTitle(lister)
//update title bar based on user changes to lister, layout, view, etc.
{
tab = lister.activetab;
cmd.SetSourceTab(tab);
tabs = tab.right;
//Determine layout type change and identify active display
dual = lister.dual;
if (dual == "1" && tabs == true)//check for dual vertical, active right display
{
activeDisplay = "Right"
} else if (dual == "1" && tabs == false)//check for dual vertical, active left display
{
activeDisplay = "Left"
} else if (dual == "2" && tabs == true)//check for dual horizontal, active bottom display
{
activeDisplay = "Bottom"
} else if (dual == "2" && tabs == false)//check for dual horizontal, active top display
{
activeDisplay = "Top"
} else//if not dual vertical or horizontal, must be a single display
{
activeDisplay = "Display"
}
//Determine view mode status change
viewMode = tab.format.view;
viewMode = viewMode.substring(0,1).toUpperCase() + viewMode.substring(1);
if (cmd.IsSet("VIEW=LargeIcons"))
{
viewMode = "Large Icons"
} else if (cmd.IsSet("VIEW=SmallIcons"))
{
viewMode = "Small Icons"
} else
{
viewMode = viewMode
}
if (cmd.IsSet("FLATVIEW=on,Grouped"))
{
viewMode += " (Flat-Grouped)"
} else if (cmd.IsSet("FLATVIEW=on,Mixed"))
{
viewMode += " (Flat-Mixed)"
} else if (cmd.IsSet("FLATVIEW=on,MixedNoFolders"))
{
viewMode += " (Flat-Mixed, No Folders)"
} else if (cmd.IsSet("VIEW=Tiles"))
{
viewMode += "s"
} else if ((cmd.IsSet("VIEW=Details")) && (cmd.IsSet("COLUMNSTOGGLE=thumbnail")))
{
viewMode += " + Thumbnails"
} else
{
viewMode = viewMode
}
//Check for quickfilter status change
quickFilterSet = tab.quickfilter.filter;
if (quickFilterSet === '')
{
quickFilterFlag = "OFF"
} else
{
quickFilterFlag = "[ " + quickFilterSet + " ]"
}
//Check for global filter status change
if (filterSet == true)
{
globalFilterFlag = "ON"
} else
{
globalFilterFlag = "OFF"
}
//Determine if hide hidden files set to true
if (cmd.IsSet("GLOBALHIDEHIDDEN=Toggle"))
{
hideHiddenFlag = "OFF"
} else
{
hideHiddenFlag = "ON"
}
//Determine if hide system files set to true
if (cmd.IsSet("HIDESYSTEMFILES=Toggle"))
{
hideSystemFlag = "OFF"
} else
{
hideSystemFlag = "ON"
}
//Build Lister Title
title = "notoggle:Directory Opus " + version + " Pro (64-bit) | LAYOUT: %L | STYLE: %S | ACTIVE: " + activeDisplay + " | VIEW: " + viewMode + " | FILTERS: Q - " + quickFilterFlag + " G - " + globalFilterFlag + " H - " + hideHiddenFlag + " S - " + hideSystemFlag
var id = tab.path.def_value;
var binid = DOpus.FSUtil.DisplayName(tab.path);
if (tab.path.test_root == 0) //Check if at root drive
{
if (id.substr(id.length - 1) == "\\")
{
title = title + " | FOLDER: %R\\"; //Ensures root drive displayed properly
} else
{
title = title + " | FOLDER: %R";
}
} else
{
if (binid.substr(binid.length - 3) == "Bin")
{
title = title + " | FOLDER: %R";
} else
{
title = title + " | FOLDER: %R\\...\\%N";
}
}
DOpus.Output(title);
DOpus.Output(DOpus.FSUtil.DisplayName(tab.path));
cmd.RunCommand('Set LISTERTITLE="' + title + '"');
}
//These functions update the lister title after specified events
function OnActivateTab(activateTabData)
{
UpdateTitle(activateTabData.newtab.lister);
}
function OnSourceDestChange(sourceDestChangeData)
{
UpdateTitle(sourceDestChangeData.tab.lister);
}
function OnAfterFolderChange(afterFolderChangeData)
{
UpdateTitle(afterFolderChangeData.tab.lister);
}
function OnDisplayModeChange(displayModeChangeData)
{
UpdateTitle(displayModeChangeData.tab.lister);
}
function OnFlatViewChange(flatViewChangeData)
{
UpdateTitle(flatViewChangeData.tab.lister);
}
The script runs fine, regardless of the layout selected. However, it generates the following error when opening or switching to a single-pane layout:
Custom Title Bar: Error at line 229, position 2
Custom Title Bar: Invalid procedure call or argument (0x800a0005)
Line 229: var binid = DOpus.FSUtil.DisplayName(tab.path);
Any ideas how to revise the script to avoid this error?
Thanks in advance!