Adding a simple script to a menu - any menu! (2024.2.0.3184)

To discuss development of addons / skins / customization of MediaMonkey v5 / v2024

Moderators: jiri, drakinite, Addon Administrators

Corneloues
Posts: 28
Joined: Thu Oct 22, 2009 4:41 am

Adding a simple script to a menu - any menu! (2024.2.0.3184)

Post by Corneloues »

HI I'm a very long-term MM4 user and have dabbled on and off with v5 and now 2024.

One of the things that has been holding me back is my library of VBScripts that I needed to convert to JavaScript.

I've now bitten the bullet and created my first script. Complete with info.json.

However, when I open MM the script never shows. I've tried every conceivable way of adding the script - even creating an mmip and adding it manually from the Addons dialog. It installs, MM restarts, but no script is visible.

I've even tried using ChatGPT and Copilot and have tried different methods of creating actions and adding to menus, but still nothing.

I've pasted the very simple "smoke test" json and js below. Can someone please tell me where I'm going wrong?

I'm not intending on making the scripts public. I just want to add them myself as I can do in MM4.

TIA,

Roy

info.json

Code: Select all

{
    "id": "SmokeTest",
    "version": "1.0.0",
    "title": "Smoke Test",
    "description": "Smoke test for menu registration.",
    "author": "Soundchaser",
    "type": "script",
    "main": "main.js",
    "minAppVersion": "5.0.0"
}
main.js

Code: Select all

// Simple function to test execution
function smokeTest() {
    app.showPopupMessage("Smoke test executed.");
}

// Register the action
actions.smokeTest = {
    title: "Smoke Test",
    icon: "",
    execute: smokeTest
};

// Register the menu item
window._menuItems.push({
    action: "smokeTest",
    path: "Tools/SmokeTest"
});
MiPi
Posts: 922
Joined: Tue Aug 18, 2009 2:56 pm
Location: Czech Republic
Contact:

Re: Adding a simple script to a menu - any menu! (2024.2.0.3184)

Post by MiPi »

Hi,
I recommend to start here: https://www.mediamonkey.com/wiki/Gettin ... 8Addons%29
Part "Actions, Hotkeys & Menus" describes how to add items to menus.
jennylynne
Posts: 31
Joined: Mon Jul 02, 2012 2:43 pm

Re: Adding a simple script to a menu - any menu! (2024.2.0.3184)

Post by jennylynne »

I am having exactly the same problem.
jennylynne
Posts: 31
Joined: Mon Jul 02, 2012 2:43 pm

Add‑on not appearing in menu in MM 5.1 (Build 2024.2.0.3184 – Gold License)

Post by jennylynne »

Hello everyone,

I’m hoping someone from Ventis Media or another developer can clarify the current behavior of user add‑ons in MediaMonkey 5.1 (build 2024.2.0.3184).

I have a Gold license, and I’ve been following the official instructions described in the wiki here:
👉https://www.mediamonkey.com/wiki/Gettin ... 8Addons%29

What I’ve done
I’ve built a very simple Auto‑Tag (JLH Metadata Rules) add‑on to test menu registration.
Following the wiki example, my files are structured as:

C:\Users\<user>\AppData\Roaming\MediaMonkey5\Scripts\JLHAutoTag\
info.json
main.js

Info.json

Code: Select all

{
  "id": "JLHAutoTag",
  "version": "1.0.0",
  "title": "Auto‑Tag (JLH Metadata Rules)",
  "description": "Auto‑tags and validates music metadata based on JLH's schema.",
  "author": "JLH",
  "minAppVersion": "5.0",
  "type": "startup",
  "main": "main.js",
  "actions": [
    {
      "id": "JLHAutoTagAction",
      "title": "Auto‑Tag (JLH Metadata Rules)",
      "tooltip": "Run JLH Auto‑Tag Add‑On",
      "group": "tagging"
    }
  ]
}
main.js

Code: Select all

'use strict';

function runJLHAutoTag() {
  try {
    alert("JLH Auto‑Tag Add‑On is running!");
  } catch (e) {
    console.error(e);
  }
}

app.addAction({
  id: "JLHAutoTagAction",
  title: "Auto‑Tag (JLH Metadata Rules)",
  group: "tagging",
  executes: runJLHAutoTag
});
I’ve packaged this into JLHAutoTag.mmip and installed it via Tools → Add‑ons → Install from file.
The installation completes without error, but no new menu item appears under Tools → Edit Tags (or anywhere else).

What I’ve verified
  • The files are in the correct \Scripts\JLHAutoTag\ folder.
  • "type": "startup" and "actions" are set correctly.
  • Tried "background" as well, same result.
  • Reinstalled several times.
  • There’s no “Developer Mode” toggle anywhere under About
Questions
  • Has support for custom add‑ons been disabled or sandboxed in build 2024.2.0.3184?
  • Is there now an internal flag or setting (such as EnableAddons, Developer Mode, etc.) required for MediaMonkey to load user‑created JavaScript extensions?
  • If so, where can it be enabled?
  • Is there updated documentation that supersedes the Getting Started (Add‑ons) page?
Any current information on how to make user actions appear again (or confirmation that this functionality has been removed) would be very helpful.

Thank you!
— JLH

MediaMonkey 5 Gold License
Build 2024.2.0.3184 
Windows 11
IanRTaylorUK
Posts: 611
Joined: Fri Dec 27, 2019 4:41 pm

Re: Add‑on not appearing in menu in MM 5.1 (Build 2024.2.0.3184 – Gold License)

Post by IanRTaylorUK »

Your add‑on is installing correctly — the issue is that defining an "action" in info.json does not automatically place it into any menu.

This is explicitly shown in the official wiki section:
➡ "Actions, Hotkeys & Menus → Adding actions to menus"
MediaMonkey 5 separates:
1. Defining an action (Which you are doing correctly with "actions" and app.addAction())
vs.
2. Adding that action to a UI menu (Which your add‑on does not do yet.)

MM5 will not show the action anywhere unless your script explicitly inserts it into a menu.

What is missing in your add‑on
Per the wiki, you must add something like:
JavaScriptrequirejs('actions'); // Needed to access menu manipulationrequirejs('menus'); // For menu APIsapp.addMenuItem({ path: 'Tools/Edit Tags', action: 'JLHAutoTagAction', order: 50});Show more lines

Without this, your action exists in MM5 internally, but is not assigned to any visible menu — so nothing appears under Tools → Edit Tags.

Try something like this:

Code: Select all

'use strict';

function runJLHAutoTag() {
  alert("JLH Auto‑Tag Add‑On is running!");
}

app.addAction({
  id: "JLHAutoTagAction",
  title: "Auto‑Tag (JLH Metadata Rules)",
  group: "tagging",
  executes: runJLHAutoTag
});

requirejs('menus');

app.addMenuItem({
    path: 'Tools/Edit Tags',
    action: 'JLHAutoTagAction',
    order: 50
});
Restart MM5 → Your action should now appear exactly where you expect.
Ian Taylor
IanRTaylorUK
Posts: 611
Joined: Fri Dec 27, 2019 4:41 pm

Re: Adding a simple script to a menu - any menu! (2024.2.0.3184)

Post by IanRTaylorUK »

The good news is: your add‑on is loading, but it will never appear anywhere because of two issues:

1). Your script doesn’t register any actions
Your JSON defines "type": "script" and "main": "main.js"
This does not register an MM5 action.
It only adds a property to a global actions object — which MM5 does not scan automatically.
Per the MM5 Add‑ons documentation, you must add actions using the API (e.g. app.addAction) in order for MM5 to know about them:

MediaMonkey 5 requires actions to be explicitly defined using its JS API, and they must be manually added to menus.

That means nothing will show unless you call:
app.addAction({...});...

2. MM5 does not automatically add actions to menus
Even when an action is defined, MM5 will not display it in any menu unless you explicitly insert it:

Add-ons must explicitly add actions to menus; MediaMonkey does not auto-place them.

Try something like:
{
"id": "SmokeTest",
"version": "1.0.0",
"title": "Smoke Test",
"description": "Smoke test for menu registration.",
"author": "Soundchaser",
"type": "startup",
"main": "main.js",
"minAppVersion": "5.0.0"
}

And:

'use strict';

function smokeTest() {
app.showPopupMessage("Smoke test executed.");
}

// 1. Register the action correctly
app.addAction({
id: "SmokeTestAction",
title: "Smoke Test",
group: "tools",
executes: smokeTest
});

// 2. Add the action to a visible menu
requirejs('menus');

app.addMenuItem({
path: 'Tools',
action: 'SmokeTestAction',
order: 50
});

After restart, you'll see:

Tools → Smoke Test

Click it and your popup (should) appear.
Ian Taylor
jennylynne
Posts: 31
Joined: Mon Jul 02, 2012 2:43 pm

Re: Add‑on not appearing in menu in MM 5.1 (Build 2024.2.0.3184 – Gold License)

Post by jennylynne »

I c+p into main.js and repacked the mmip. I reinstalled and restarted MM5, but I still don't see it in Tools->Edit tags.

Jen
IanRTaylorUK
Posts: 611
Joined: Fri Dec 27, 2019 4:41 pm

Re: Adding a simple script to a menu - any menu! (2024.2.0.3184)

Post by IanRTaylorUK »

This is a README.MD

Code: Select all

# AutoJLHTag (MediaMonkey 5 Add-on)

**Author:** JLH  
**Version:** 1.0.1  
**Type:** Metadata Add-on  

## Description
This add-on automates and validates music metadata based on specific JLH schema rules. It adds a custom command to the "Edit Tags" submenu in MediaMonkey 5.

## Manual Installation (No MMIP)
To install this add-on manually, ensure the following files are placed in the correct directory:

1. **Path:** `%AppData%\Roaming\MediaMonkey5\Scripts\JLHAutoTag\`
2. **Files required:**
   - `info.json`: Extension manifest.
   - `action_add.js`: Main script logic.
   - `README.md`: This documentation file.

## Configuration Details
- **info.json**: Must have `"type": "metadata"` and `"main": "action_add.js"` to load correctly.
- **action_add.js**: Uses the `window._menuItems.editTags` global to hook into the UI.

## Troubleshooting
- **Menu not showing?** - Ensure you have **selected a track** in the library. The menu is context-sensitive and will not appear without a selection.
  - Check that the folder name (`JLHAutoTag`) matches the `id` in `info.json` exactly.
  - Verify the file is named `action_add.js` and not `action_add.js.txt`.
- [cite_start]**Debug Mode:** Press `F12` in MediaMonkey to check the console for script errors[cite: 4].

## Version History
- **1.0.1**: Initial test version with basic menu injection and alert feedback.
- **1.0.0**: Original startup script concept.
Ian Taylor
IanRTaylorUK
Posts: 611
Joined: Fri Dec 27, 2019 4:41 pm

Re: Adding a simple script to a menu - any menu! (2024.2.0.3184)

Post by IanRTaylorUK »

This is the info.json

Code: Select all

{
    "id": "JLHAutoTag",
    "version": "1.0.1",
    "title": "AutoJLHTag",
    "description": "Automates and validates music metadata based on JLH's schema.",
    "author": "JLH",
    "type": "metadata",
    "main": "init.js"
}
Ian Taylor
IanRTaylorUK
Posts: 611
Joined: Fri Dec 27, 2019 4:41 pm

Re: Adding a simple script to a menu - any menu! (2024.2.0.3184)

Post by IanRTaylorUK »

And this is the init.js file with a bunch of comments!

Please try and hopefully you will see the menu and the pop-up.

Apologies if the "text" is not quite right.

Code: Select all

// 'use strict' forces the browser to catch common coding mistakes [cite: 4]
'use strict';

(function() {
    /**
     * Define the action object in the global 'actions' namespace.
     * MediaMonkey uses this to track clickable commands[cite: 1, 5].
     */
    actions.AutoJLHTag = {
        // The display name in the menu
        title: _('AutoJLHTag (Test)'),
        // Enables keyboard shortcut support in settings
        hotkeyAble: true,
        // Greys out the item if no tracks are selected 
        disabled: uitools.notMediaListSelected,
        // Hides the item if tags cannot be edited (e.g., read-only files) 
        visible: window.uitools.getCanEdit,
        // The function that runs when clicked
        execute: async function () {
            alert("The menu item is working!");
        }
    };

    /**
     * Function to safely inject the menu item.
     * Sometimes the menu isn't fully built when the script first loads.
     */
    const injectMenu = function() {
        if (window._menuItems && window._menuItems.editTags) {
            window._menuItems.editTags.action.submenu.push({
                action: actions.AutoJLHTag,
                // order: 10 - Positions it at the top of the section
                order: 10,
                // grouporder: 10 - Places it in the primary tagging block
                grouporder: 10 
            });
            console.log("AutoJLHTag: Menu item injected successfully.");
        } else {
            // If the menu isn't ready, wait 200ms and try again
            setTimeout(injectMenu, 200);
        }
    };

    // Start the injection process
    injectMenu();
})();
Ian Taylor
IanRTaylorUK
Posts: 611
Joined: Fri Dec 27, 2019 4:41 pm

Re: Adding a simple script to a menu - any menu! (2024.2.0.3184)

Post by IanRTaylorUK »

I will try to send you a separate "link" for the "Gem" I have used!
Ian Taylor
Post Reply