Option Explicit ' Album Double-Click ' (c) 2014-2016 Leo Davidson ' ' This is a script for Directory Opus. ' See http://www.gpsoft.com.au/redirect.asp?page=scripts for development information. ' ' This script makes it so double-clicking a music album folder thumbnail will play the album ' instead of entering the folder. ' ' It works by changing what double-click does when in thumbnails mode for specific folders ' (which you can configure). To play the album, it searches the for an .m3u playlist within ' the folder you double-clicked. ' ' Since this only affects thumbnails mode, the script can be left enabled and your album ' folders can still be managed in details mode normally, while Opus turns into a music ' selection UI when you switch to thumbnails mode in the chosen folders. ' Called by Directory Opus to initialize the script Function OnInit(initData) ' Provide basic information about the Script initData.name = "Album Double-Click" initData.version = "1.2" initData.desc = "Double-click music album thumbnails to play them" initData.copyright = "(c) 2014-2016 Leo Davidson" initData.default_enable = true Dim vecDefFolders Set vecDefFolders = DOpus.NewVector ' Default folders / example config. vecDefFolders.push_back("/profile\Music") vecDefFolders.push_back("D:\Audio\Music Albums") initData.config.AlbumFolders = vecDefFolders initData.config_desc = DOpus.Create.Map("AlbumFolders", "List of folders the script should affect.") 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 ' Called on double-click. Function OnDoubleClick(doubleClickData) ' Don't change anything if we're not in thumbnails mode. If (doubleClickData.tab.format.view <> "thumbnails") Then Exit Function End If ' Only affect left button double-clicks, with no qualifiers held down. If (doubleClickData.mouse <> "left" Or doubleClickData.qualifiers <> "none") Then Exit Function End If ' Cache the FSUtil object, for efficiency. Dim fsu Set fsu = DOpus.FSUtil ' Don't change anything if we're not in one of the configured folders. If (Not IsPathInVector(fsu, doubleClickData.tab.Path, Script.config.AlbumFolders)) Then Exit Function End If ' Don't change anything if the double-clicked item is not a folder. If (Not doubleClickData.item.is_dir) Then Exit Function End If ' Look for a .M3U or .M3U8 file below the folder. Dim folderEnum Set folderEnum = fsu.ReadDir(doubleClickData.item, false) Dim childItem Do While (Not folderEnum.Complete) Set childItem = folderEnum.Next ' Check for a .m3u extension. This also has the effect of ignoring folders, ' since folders always have an empty extension property (even if they ' have a name containing a dot), so we don't have to check that separately. If (childItem.ext = ".m3u" or childItem.ext = ".m3u8") Then ' Launch the .m3u file we found. DOpus.NewCommand.RunCommand """" & childItem & """" ' Prevent the standard double-click action. OnDoubleClick = True Exit Function End If Loop End Function