Classification (Tempo, Mood, Occasion, Quality) Menu in Tray

Post a reply

In an effort to prevent automatic submissions, we require that you complete the following challenge.
:D :) :( :o :-? 8) :lol: :x :P :oops: :cry: :evil: :roll: :wink:

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review

Expand view Topic review: Classification (Tempo, Mood, Occasion, Quality) Menu in Tray

helpfile problem

by johnbot » Thu Aug 02, 2007 10:30 am

THX for figuring out the Codpageconversion list thing. Had the same problem, your solution worked for me.

by streawkceur » Sun Feb 04, 2007 10:10 am

Hm, your event registering code doesn't differ much from what the script already uses. You only pass the "btnOK.Common" obeject instead of "btnOK" itself.

So I have to store the menu type somewhere, if no parameterised events exist. As you cannot store additional information in the MenuItem object itself, I've done that using a dictionary... Seems like a hack, but not as bad as 8 dummy subs.

The code has been updated.

by streawkceur » Sun Feb 04, 2007 9:21 am

I just downloaded this file but had no luck. It's still not working. I have even upgraded to IE7, but it didn't help. As I've mentioned, I have no option to unblock the file. In the right pane the page is in a loading/waiting state, which will not proceed. See the (german) screenshot:


I can abort it in the options menu and then an IE error page shows up: "cannot connect to that site".

The IE settings are at their defaults. I have no idea, what else to do (besides reinstalling windows, haha). Bad luck.

So I decompiled the CHM with chmview ( ) and tried to load the HTML files manually. In Firefox it works, in IE it doesn't. The reason seems to be the greek charset:

Code: Select all

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-7"/>
When I remove the charset, it works in IE.

So I digged around in the system settings and found out, that the page (and then also the CHM) works, if I disable this (translated from german):

System Settings -> Region and language settings -> Advanced -> Codpageconversion list -> Uncheck "28597 (ISO 8859-7 Greek)"

Funky, isn't it?

by Steegy » Sun Feb 04, 2007 7:25 am

1. Don't feel sorry. I just wanted to get the message out, that's all.

2. Are you sure you are trying this chm file: ... ipting.chm ?
Without scripting chm file, it's hard to do more than just the standard stuff with MM scripting (as you don't really see what's possible and what not). I really hope that you can get the chm working someway, as it's needed.

3. (the new) events are registered like this:

Code: Select all

Sub OnStartup
    Dim btnOK : Set btnOk = CreateOKButton()
    Script.RegisterEvent btnOK.Common, "OnClick", "btnOk_OnClick"
End Sub

Sub btnOk_OnClick(Button)
    MsgBox "The button click was handled by the Common.OnClick event handler"
End Sub

Function CreateOKButton()
    ' Create and return the OK button here
    'Set CreateOKButton = ...
End Function

by streawkceur » Sun Feb 04, 2007 5:30 am

Well, imho the topic really didn't fit anymore. The proper keywords for this script clearly are "classification, tray, mood, tempo, occasion, quality". Only one ("tray") of this keywords can be found in the title "change (add) the tray MM icon options?". If you still disagree, I have no problem with posting this one in the original thread and closing this one.

Don't get me wrong. I don't want to exploit your work to gain personal reputation or something. I gave you credit in two places in my posting.
I'm sorry that I didn't contact you privately before, but my experience in "open source" development (hm, maybe this scripts aren't?) is to release early and often. The only one you could harm with your bad code is yourself, so I didn't see a problem.

After all, I'm sorry if I offended someone with my release or broke some ethical rules I didn't notice yet.
To get the scripting help file (chm) working, you have to "de-block" it. You can do that in the file properties.
Yeah, I've read in a thread about that. I simply don't have such a "de-block" possibility in the file properties. Nor can I find anything related in the CHM reader. Additionally every other CHM works flawlessly. I have no idea.

Do you know how to register for parameterised event callbacks? Is it possible at all?

by Steegy » Sat Feb 03, 2007 2:27 pm


To get the scripting help file (chm) working, you have to "de-block" it. You can do that in the file properties.

Classification (Tempo, Mood, Occasion, Quality) Menu in Tray

by streawkceur » Sat Feb 03, 2007 2:01 pm


Based on (thanks Steegy) I've created a modified version of this script, which allows the modification of all classification criteria and not only the mood.

Additionally, the state "None" will be recognized correctly in the menu.


Code: Select all

' MEDIAMONKEY SCRIPT: TrayClassification v1.1 (last updated 2007-02-04)
' Original by Steegy:
' Extended by streawkceur:
' TrayClassification will add submenus for the classification (temp, mood, occasion,
' quality)of the current songs to the tray menu.

Option Explicit

Public ClassificationTypes(4)
ClassificationTypes(1) = "Tempo"
ClassificationTypes(2) = "Mood"
ClassificationTypes(3) = "Occasion"
ClassificationTypes(4) = "Quality"

'Store the classification class for each menu entry in this dictionary
'as we otherwise don't know to which class a menu item belongs
Public ClassByMenuItem
Set ClassByMenuItem = CreateObject("Scripting.Dictionary")

Sub OnStartup
	Dim i
	For i = 1 To 4
		Dim MenuItem
		Set MenuItem = SDB.UI.AddMenuItemSub(SDB.UI.Menu_TrayIcon, 1, 2)
		MenuItem.Caption = SDB.Localize(ClassificationTypes(i))
		MenuItem.IconIndex = 42
		Script.RegisterEvent MenuItem, "OnClick", "ClassMenuClick"
		ClassByMenuItem.Add MenuItem, i
End Sub

Sub ClassMenuClick(MI)
	'Which classification menu has been clicked?
	Dim ClassificationType
	ClassificationType = ClassByMenuItem.Item(MI)
	'Fill the tray classification list
	Dim Iter, MSI, Localised, ObjectPrefix, ObjectName
	Set Iter = SDB.Database.OpenSQL("SELECT TextData FROM Lists WHERE IDListType = " & ClassificationType & " ORDER BY SortOrder")
	ObjectPrefix = "Tray_" & ClassificationTypes(ClassificationType) & "_"
	Do While Not Iter.EOF
		Localised = SDB.LocalizeGen("DB", Iter.StringByIndex(0))
		ObjectName = ObjectPrefix & Localised
		If SDB.Objects(ObjectName) Is Nothing Then
			Set MSI = SDB.UI.AddMenuItem(MI, 0, 0)
			MSI.Caption = Localised
			MSI.IconIndex = 64
			Script.RegisterEvent MSI, "OnClick", "ClassSubmenuClick"
			Set SDB.Objects(ObjectName) = MSI
			ClassByMenuItem.Add MSI, ClassificationType
		End If
		SDB.Objects(ObjectName).Checked = False
	'Check the classification for the currently playing song
	Dim CurrentSong : Set CurrentSong = SDB.Player.CurrentSong
	If Not CurrentSong Is Nothing Then
		Dim Value
		Select Case ClassificationType
			Case 1 'Tempo
				Value = CurrentSong.Tempo
			Case 2 'Mood
				Value = CurrentSong.Mood
			Case 3 'Occasion
				Value = CurrentSong.Occasion
			Case 4 'Quality
				Value = CurrentSong.Quality
		End Select
		If Value = "" Then Value = SDB.LocalizeGen("DB", "None")
		If Not SDB.Objects(ObjectPrefix & Value) Is Nothing Then
			SDB.Objects(ObjectPrefix & Value).Checked = True
		End If
	End If
End Sub

Sub ClassSubmenuClick(MSI)
	'In which classification submenu has an item been clicked?
	Dim ClassificationType
	ClassificationType = ClassByMenuItem.Item(MSI)
	'Store the chosen categorization to the song's properties
	Dim CurrentSong : Set CurrentSong = SDB.Player.CurrentSong
	If Not CurrentSong Is Nothing Then
		Select Case ClassificationType
			Case 1 'Tempo
				CurrentSong.Tempo = MSI.Caption
			Case 2 'Mood
				CurrentSong.Mood = MSI.Caption
			Case 3 'Occasion
				CurrentSong.Occasion = MSI.Caption
			Case 4 'Quality
				CurrentSong.Quality = MSI.Caption
		End Select
		Dim SongList : Set SongList = SDB.NewSongList
		Call SongList.Add(CurrentSong)
		Call SongList.UpdateAll
	End If
End Sub

Just put it in the MediaMonkey\Scripts\Auto folder.

  • The icons do not fit very well. Unfortunately you cannot use folder icons for menu entries. At least I don't know how you could. Anyone else?