Create a File EditCustomX.vbs in the MM\Scripts\Auto Folder and paste the code from below!
It will create SubMenus in most Pop-Ups.
This example is for adding/removing the Language to the CustomField 2. (changeable in line 6)
When Changing the Constant OnlyOneSelection (line 7) to False, it is possible to Add more than One Language to one Song or, like in the Picture, more than one Keyword.
Customize it for your Needs!

Code: Select all
Option Explicit
'#################################################
' User-defined Settings
'#################################################
const CustomField = 2 'which Custom Field should be edited MM2: 1..3; MM3: 1..5
const OnlyOneSelection = True 'should the Selection be removed/added to the custom field or should the field be replaced/cleared
Dim dictCustomEntries
Set dictCustomEntries = CreateObject("Scripting.Dictionary")
dictCustomEntries.Add 1, "deutsch"
dictCustomEntries.Add 2, "englisch"
dictCustomEntries.Add 3, "französisch"
dictCustomEntries.Add 4, "finnisch"
dictCustomEntries.Add 5, "italienisch"
dictCustomEntries.Add 6, "japanisch"
dictCustomEntries.Add 7, "spanisch"
'#################################################
' Start-Up Function (Create Menu Icons)
'#################################################
Dim objMenu
Dim iniField
objMenu = "mnuCustom" & CustomField
iniField = "Fld" & CustomField & "Name"
Sub OnStartUp
Dim MenuItem
Dim Typ
Typ = "Tray"
set MenuItem = SDB.Objects(objMenu & Typ)
if MenuItem is nothing then
set MenuItem = SDB.UI.AddMenuItemSub(SDB.UI.Menu_TrayIcon, 0, 0)
MenuItem.Caption = SDB.INIFile.StringValue("CustomFields", iniField)
MenuItem.Hint = Typ
MenuItem.Enabled = True
MenuItem.UseScript = Script.ScriptPath
MenuItem.OnClickFunc = "AddSubMenuItems"
SDB.Objects(objMenu) = MenuItem
AddSubMenuItems(MenuItem)
end if
Typ = "NP"
set MenuItem = SDB.Objects(objMenu & Typ)
if MenuItem is nothing then
set MenuItem = SDB.UI.AddMenuItemSub(SDB.UI.Menu_Pop_NP, 0, -1)
MenuItem.Caption = SDB.INIFile.StringValue("CustomFields", iniField)
MenuItem.Hint = Typ
MenuItem.Enabled = True
MenuItem.UseScript = Script.ScriptPath
MenuItem.OnClickFunc = "AddSubMenuItems"
SDB.Objects(objMenu) = MenuItem
AddSubMenuItems(MenuItem)
end if
Typ = "Main"
set MenuItem = SDB.Objects(objMenu & Typ)
if MenuItem is nothing then
set MenuItem = SDB.UI.AddMenuItemSub(SDB.UI.Menu_Pop_TrackList, 0, -1)
MenuItem.Caption = SDB.INIFile.StringValue("CustomFields", iniField)
MenuItem.Hint = Typ
MenuItem.Enabled = True
MenuItem.UseScript = Script.ScriptPath
MenuItem.OnClickFunc = "AddSubMenuItems"
SDB.Objects(objMenu) = MenuItem
AddSubMenuItems(MenuItem)
end if
Set MenuItem = Nothing
end Sub
'#################################################
' Add Sub-Menus (Custom Entries)
'#################################################
Sub AddSubMenuItems(Node)
Dim a
Dim SubEntry
Dim Track
Dim Entry
Dim ObjName
Dim Typ
Typ = Node.Hint
for a = 1 to dictCustomEntries.Count
ObjName = objMenu & Typ & a
set SubEntry = SDB.Objects(ObjName)
if SubEntry is Nothing then
set SubEntry = SDB.UI.AddMenuItem(Node, 1, -1)
'MenuItem.IconIndex = 56
SubEntry.Caption = dictCustomEntries.Item(a)
SubEntry.Hint = Typ
SubEntry.Enabled = True
SubEntry.UseScript = Script.ScriptPath
SubEntry.OnClickFunc = "SetCustom"
SDB.Objects(ObjName) = SubEntry
end if
Dim Tracks
if Typ = "NP" then
Set Tracks = SDB.SelectedSongList
elseif Typ = "Main" then
Set Tracks = SDB.SelectedSongList
elseif Typ = "Tray" then
Set Tracks = SDB.NewSongList
if not (SDB.Player.CurrentSong is nothing) then Tracks.Add(SDB.Player.CurrentSong)
end if
if Tracks.Count = 1 then
Set Track = Tracks.Item(0)
Select case CustomField
Case 1
Entry = Track.Custom1
Case 2
Entry = Track.Custom2
Case 3
Entry = Track.Custom3
Case 4
Entry = Track.Custom4
Case 5
Entry = Track.Custom5
end select
SubEntry.Checked = Instr(1, Entry, dictCustomEntries.Item(a), 1)
Set Track = Nothing
else
SubEntry.Checked = False
end if
Set SubEntry = Nothing
next
End Sub
'#################################################
' Change Custom Entries
'#################################################
Sub SetCustom(Node)
Dim Entry
Dim Typ
Typ = Node.Hint
Dim Tracks
if Typ = "NP" then
Set Tracks = SDB.SelectedSongList
elseif Typ = "Main" then
Set Tracks = SDB.SelectedSongList
elseif Typ = "Tray" then
Set Tracks = SDB.NewSongList
if not (SDB.Player.CurrentSong is nothing) then Tracks.Add(SDB.Player.CurrentSong)
end if
Dim Track
Dim a
for a = 0 to Tracks.Count -1
Set Track = Tracks.Item(a)
Select Case CustomField
Case 1
Entry = Track.Custom1
Case 2
Entry = Track.Custom2
Case 3
Entry = Track.Custom3
Case 4
Entry = Track.Custom4
Case 5
Entry = Track.Custom5
end Select
if OnlyOneSelection then
if LCase(Entry) = LCase(Node.Caption) then
Entry = ""
else
Entry = Node.Caption
end if
else
if InStr(1, Entry, Node.Caption, 1) then
'remove KeyWord
while InStr(1, Entry, Node.Caption, 1)
Entry = Replace(Entry, Node.Caption, "", 1, -1, 1)
Wend
'clean String
while InStr(1, Entry, " ", 1)
Entry = Replace(Entry, " ", " ", 1, -1, 1)
Wend
while InStr(1, Entry, ", ,", 1)
Entry = Replace(Entry, ", ,", ",", 1, -1, 1)
Wend
while InStr(1, Entry, ",,", 1)
Entry = Replace(Entry, ",,", ",", 1, -1, 1)
Wend
else
'Add KeyWord
if Entry <> "" then Entry = Entry & ", "
Entry = Entry & Node.Caption
end if
'Clean string
Entry = Trim(Entry)
While Right(Entry, 1) = ","
Entry = Left(Entry, Len(Entry)-1)
Entry = Trim(Entry)
Wend
While Left(Entry, 1) = ","
Entry = Mid(Entry, 2)
Entry = Trim(Entry)
Wend
end if
Select Case CustomField
Case 1
Track.Custom1 = Entry
Case 2
Track.Custom2 = Entry
Case 3
Track.Custom3 = Entry
Case 4
Track.Custom4 = Entry
Case 5
Track.Custom5 = Entry
end Select
Track.UpdateDB
Set Track = Nothing
next
end Sub