This script should not be necessary anymore.
:: StartupNode's own forum post.
Description:
The StartupNode script automaticly opens or selects the last opened or an explicitly specified tree node, when MediaMonkey starts.
To set a tree node as startup node, right click the node and choose "Set as startup node".
Settings are available in the menu Edit > StartupNode submenu.
The script needs MediaMonkey version 2.5.2 or above.
Installing automaticly:
Installer for version 1.1 (latest, updated 31.03.2006): http://home.scarlet.be/ruben.castelein/ ... ode1.1.exe
Just run the exe and follow the instructions.
Installing manually:
For people that have an older version of the script:
In this new version, the script is standalone. That means that you don't need the StoreStartupAndFavouriteNodes and starter script anymore.
Notice that the folder for the StartupNode script has changed from Scripts to Scripts\Auto.
This newer version uses new built in functionality in MediaMonkey, so it will work faster.
The script consists of 1 standalone script file ("StartupNode.vbs").
StartupNode.vbs (for the Scripts\Auto folder)
Code: Select all
'==========================================================================
'
' MediaMonkey Script
'
' NAME: StartupNode v1.1
' DESCRIPTION:
' Automaticly opens or selects a specified tree node when MediaMonkey starts.
'
' AUTHOR: Steegy aka RC (Ruben Castelein)
' DATE : 15.12.2005
' UPDATE: 31.03.2006
'
' INSTALL:
' - Copy script to MediaMonkey's "Scripts\Auto" folder
'
' The script needs MediaMonkey version 2.5.2 or above.
'
' The script's settings in the "Variable Configuration" section can be modified
'
'==========================================================================
'>> ForumURL: http://www.mediamonkey.com/forum/viewtopic.php?t=7490
'>> ScriptName: StartupNode
'>> VersionNumber: 1.1
'>> Author: Steegy aka RC (Ruben Castelein)
'>>>>EndOfProperties
'##############################################################################################
'%%%%%%%%%%%%%%%%%%%%%
' Script declarations:
'%%%%%%%%%%%%%%%%%%%%%
Option Explicit
Dim splitString
splitString = "§$§$§"
Dim StartupNodeArray
Dim MessageHeader
MessageHeader = "StartupNode:" & vbNewline & vbNewline
'##############################################################################################
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
' Variable Configuration: (HERE YOU CAN MAKE SOME CHANGES IF YOU WANT)
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'
Dim Error_BrowseToNode
Error_BrowseToNode = "An error occured while auto-opening the specified node. "_
& "Possibly, the node specification is incorrect."_
& vbNewline & "The node has been opened as far as possible."
Dim isStartupNodeExpanded ' Expand (True) or don't expand (False) the startup node
isStartupNodeExpanded = True
Dim LaunchTimerTimeout 'If the scripts gives you an error when MediaMonkey starts, then try
LaunchTimerTimeout = 0 ' to set LaunchTimerTimeout to a higher value in milliseconds (e.g. 500)
'This is sometimes necessary if you have a "My Computer" or "Magic Nodes"
' subnode as startup node (especially on slower computers)
'##############################################################################################
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
' The subroutines and functions that make this text file a "program":
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Sub OnStartup
' Starts the actual script
' Registers the OnShutdown Event when the right version is installed
If CurrentVersion >= 252 Then
Script.RegisterEvent SDB, "OnShutdown", "setStartupNodeOnShutdown"
End If
' Adds item miSetAsStartupNode to the tree node popup menu
Dim miSetAsStartupNode
Set miSetAsStartupNode = SDB.UI.AddMenuItem(SDB.UI.Menu_Pop_Tree,0,0)
With miSetAsStartupNode
.Caption = "Set as startup node"
.OnClickFunc = "setAsStartupNode"
.UseScript = Script.ScriptPath
.IconIndex = 22
If SDB.IniFile.StringValue("StartupNode", "ShowContextItem") <> "False" Then
.Visible = True
End If
End With
Set SDB.Objects("StartupNodeContextItem") = miSetAsStartupNode
' Adds the mStartupNode submenu and adds 3 items (miStartupNodeEnabled and miStartupNodeAutoSet and miStartupNodeHide)
SDB.UI.AddMenuItemSep SDB.UI.Menu_Edit,0,0
Dim mStartupNode
Set mStartupNode = SDB.UI.addMenuItemSub(SDB.UI.Menu_Edit,0,0)
With mStartupNode
.Caption = "StartupNode"
.IconIndex = 22
.useScript = Script.ScriptPath
End With
Dim miStartupNodeEnabled
Set miStartupNodeEnabled = SDB.UI.AddMenuItem(mStartupNode,0,0)
With miStartupNodeEnabled
.Caption = "StartupNode enabled"
.Hint = "Enables StartupNode so MediaMonkey will start on the startup node"
.OnClickFunc = "setStartupNodeEnabled"
.UseScript = Script.ScriptPath
If SDB.IniFile.StringValue("StartupNode", "Enabled") = "True" Then
.Checked = True
End If
End With
Set SDB.Objects("StartupNodeEnabledMenuItem") = miStartupNodeEnabled
Dim miStartupNodeAutoSet
Set miStartupNodeAutoSet = SDB.UI.AddMenuItem(mStartupNode,0,0)
With miStartupNodeAutoSet
.Caption = "Set last node as startup node"
.Hint = "If this is set, MediaMonkey will start with the node that was last used"
.OnClickFunc = "setStartupNodeAutoSet"
.UseScript = Script.ScriptPath
If SDB.IniFile.StringValue("StartupNode", "AutoSet") = "True" Then
.Checked = True
End If
End With
Set SDB.Objects("StartupNodeAutoSetMenuItem") = miStartupNodeAutoSet
If CurrentVersion < 252 Then
miStartupNodeAutoSet.Common.Enabled = False
End If
Dim miStartupNodeHide
Set miStartupNodeHide = SDB.UI.AddMenuItem(mStartupNode,0,0)
With miStartupNodeHide
.Caption = "Shows node context menu item"
.Hint = "Sets whether or not to show the node context menu item"
.OnClickFunc = "setStartupNodeContextItemVisibility"
.UseScript = Script.ScriptPath
If SDB.IniFile.StringValue("StartupNode", "ShowContextItem") <> "False" Then
.Checked = True
End If
End With
If miStartupNodeHide.Checked = False Then
SDB.Objects("StartupNodeContextItem").Visible = False
End If
If SDB.IniFile.StringValue("StartupNode", "Enabled") <> "True" Then Exit Sub
If InitialiseStartupNode = False Then Exit Sub
Dim LaunchTimer
Set LaunchTimer = SDB.CreateTimer(LaunchTimerTimeout)
Script.RegisterEvent LaunchTimer, "OnTimer", "LaunchTimer_OnTimer"
End Sub
Sub LaunchTimer_OnTimer(Timer)
Script.UnregisterEvents Timer
Dim Result
Result = BrowseToNode(StartupNodeArray)
If Result = False Then
SDB.MessageBox MessageHeader & Error_BrowseToNode , mtError, Array(mbOk)
End If
End Sub
Function InitialiseStartupNode
InitialiseStartupNode = False
Dim PathToNode
PathToNode = SDB.IniFile.StringValue("StartupNode", "StartupNode")
If PathToNode = "" Then Exit Function
Dim PathToNodeArray
PathToNodeArray = Split(PathToNode, splitString)
StartupNodeArray = PathToNodeArray
InitialiseStartupNode = True
End Function
Function BrowseToNode(FullPathToNode)
' Browses to the specified node and returns True on success.
On Error Resume Next
Dim Node2B
Set Node2B = SDB.MainTree.Node_NowPlaying
Dim i
For i = 1 To UBound(FullPathToNode)
If i > 1 Then
Node2B.Expanded = True
Set Node2B = SDB.MainTree.FirstChildNode(Node2B)
End If
If Not Node2B.Caption = FullPathToNode(i) Then
Do
Set Node2B = SDB.MainTree.NextSiblingNode(Node2B)
If Err <> 0 Then Exit Function
Loop While Node2B.Caption <> FullPathToNode(i)
End If
Next
SDB.MainTree.CurrentNode = Node2B
Node2B.Expanded = isStartupNodeExpanded
BrowseToNode = True
End Function
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
' StartupNode properties: Enable, AutoSet and Hide
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'
Sub setStartupNodeEnabled(Item)
Item.Checked = Not Item.Checked
If Item.Checked = True Then
SDB.IniFile.StringValue("StartupNode", "Enabled") = "True"
Else
SDB.IniFile.StringValue("StartupNode", "Enabled") = "False"
End If
End Sub
Sub setStartupNodeAutoSet(Item)
Item.Checked = Not Item.Checked
If Item.Checked = True Then
SDB.IniFile.StringValue("StartupNode", "AutoSet") = "True"
Else
SDB.IniFile.StringValue("StartupNode", "AutoSet") = "False"
End If
End Sub
Sub setStartupNodeContextItemVisibility(Item)
Item.Checked = Not Item.Checked
If Item.Checked = True Then
SDB.Objects("StartupNodeContextItem").Visible = True
SDB.IniFile.StringValue("StartupNode", "ShowContextItem") = "True"
Else
SDB.Objects("StartupNodeContextItem").Visible = False
SDB.IniFile.StringValue("StartupNode", "ShowContextItem") = "False"
End If
End Sub
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
' OnShutdown event handler: save last node as startup node (for MM 2.5.2+)
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'
Sub setStartupNodeOnShutdown
If SDB.Objects("StartupNodeAutoSetMenuItem").Checked = True Then
Dim FavouriteName
FavouriteName = "StartupNode"
Dim PathToNode
PathToNode = GetPathToNode(SDB.MainTree.CurrentNode)
SDB.IniFile.StringValue("StartupNode", "StartupNode") = FavouriteName & splitString & PathToNode
End If
End Sub
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
' setAsStartupNode
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'
Sub setAsStartupNode(arg)
Dim FavouriteName
FavouriteName = "StartupNode"
Dim PathToNode
PathToNode = GetPathToNode(SDB.MainTree.CurrentNode)
SDB.IniFile.StringValue("StartupNode", "StartupNode") = FavouriteName & splitString & PathToNode
Dim StartupNodeEnabledMenuItem
Set StartupNodeEnabledMenuItem = SDB.Objects("StartupNodeEnabledMenuItem")
StartupNodeEnabledMenuItem.Checked = True
SDB.IniFile.StringValue("StartupNode", "Enabled") = "True"
Dim miStartupNodeAutoSet
Set miStartupNodeAutoSet = SDB.Objects("StartupNodeAutoSetMenuItem")
miStartupNodeAutoSet.Checked = False
SDB.IniFile.StringValue("StartupNode", "AutoSet") = "False"
End Sub
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
' Some utility functions
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'
Function CurrentVersion
CurrentVersion = SDB.VersionHi & SDB.VersionLo & SDB.VersionRelease
End Function
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
' Functions to get the path to the wanted node
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'
Function GetPathToNode(myNode)
On Error Resume Next
Dim myNode2
Dim ParentNode
Set ParentNode = myNode
GetPathToNode = myNode.Caption
Do While True
Set myNode2 = SDB.MainTree.ParentNode(ParentNode)
If myNode2 Is ParentNode Then
Exit Do
End If
Set ParentNode = myNode2
GetPathToNode = ParentNode.Caption & splitString & GetPathToNode
Loop
End Function
In-depth information:
The script uses configuration entries in MediaMonkey's ini file.
Example:
Code: Select all
[StartupNode]
AutoSet=True
Enabled=True
StartupNode=StartupNode§$§$§Library§$§$§Previews
ShowContextItem=True
Enabled: Sets StartupNode enabled so it will open the defined node at startup
ShowContextItem: Show the context menu entry for tree nodes, to set that node as startup node
StartupNode: Path to the startup node
_In this example StartupNode§$§$§Library§$§$§Previews
_The first (name) is always StartupNode
_The rest is the path to the specified tree node (tree levels indicated by §$§$§), so the tree node's location is Library > Previews
These values can be changed from within MediaMonkey.
Settings submenu in MediaMonkey's Edit menu: