Option Explicit Function OnInit(initData) initData.name = "Flat-View Auto" initData.version = "1.0" initData.desc = "Automatically turn on Flat View when entering configured folders" initData.copyright = "(c) 2015 Leo Davidson" initData.default_enable = true Dim vecDefFolders Set vecDefFolders = DOpus.Create.Vector ' Default folders / example config. vecDefFolders.push_back("/desktop") vecDefFolders.push_back("C:\Program Files\GPSoftware\Directory Opus") initData.config.FlatViewCommand = "Set FLATVIEW=On,Grouped" initData.config.FlatViewFolders = vecDefFolders initData.config_desc = DOpus.Create.Map( _ "FlatViewCommand", "Command to run when triggered.", _ "FlatViewFolders", "Folders which trigger the command.") End Function ' Helper Function Function IsPathInVector(fsu, path, vecFolders) IsPathInVector = False ' Resolve aliases, libraries, etc. to their real/absolute paths. path = fsu.Resolve(path) Dim testPath For Each testPath in vecFolders If (fsu.ComparePath(path, fsu.Resolve(testPath))) Then IsPathInVector = True Exit Function End If Next End Function Function OnAfterFolderChange(afterFolderChangeData) If (Not afterFolderChangeData.result) Then Exit Function ' Folder didn't change. End If ' Un-comment to make qualifiers (e.g. Alt, Shift, Ctrl) temporarily disable the script. ' If (afterFolderChangeData.qualifiers <> "none") Then ' Exit Function ' End If If (Not IsPathInVector(DOpus.FSUtil, afterFolderChangeData.tab.Path, Script.config.FlatViewFolders)) Then Exit Function End If Dim cmd Set cmd = DOpus.Create.Command cmd.SetSourceTab afterFolderChangeData.tab cmd.RunCommand Script.config.FlatViewCommand End Function