Page 1 of 1

Beginner question about debugging scripts

Posted: Sat Mar 12, 2022 6:54 pm
by mms1234
Hi everyone, I've been a mediamonkey 4 user for a while and have a couple VBScripts scripts that I am trying to convert to media monkey 5 javascripts. Right now I am just starting with the basics, I have created an action, and a menu entry for it. I can launch a dialog window from there. Next step is to loop through the selected tracks, and popup a dialog window with the title for each track. But for some reason my script is dying and I can't figure out why. I have read the documentation, but I am still completely confused as to how to enter development mode and bring up a console or debugger. I have tried:

1) Hitting ctrl-alt-shift
2) right clicking anywhere (as the doc says) to bring up menu option
3) open Help->About menu
4) putting app.enabledDeveloperMode = true in my code

None of these seem to do anything, and I am struggling to find any documentation on how to go about debugging scripts in MM5. I would appreciate any pointers.
Also, is it standard practice to have to restart MM everytime you change a script?

Re: Beginner question about debugging scripts

Posted: Sun Mar 13, 2022 1:31 am
by drakinite
Hi, welcome to MM addon development!

- To use the Ctrl + Alt + Shift shortcut, and to get the "Inspect Element" menu item, you need to install a debug build from the test builds thread: https://www.mediamonkey.com/forum/viewt ... 86639&sd=d
- However, on a non-debug build, you can still open the debug console. In a browser window, navigate to http://localhost:9222. To inspect the main window, click on mainwindow.html.
- All the "Developer mode" toggle does is disable the automatic sending of crash logs. (It's certainly useful, but won't let you view the console.)

Re restarting MM: The short answer is yes, but there's a long answer:
- Any code that runs in the main window, like in actions_add.js, or if you define new controls in controls/(filename).js, will require you to restart MediaMonkey when you change it.
- However, code that defines dialogs is automatically reloaded every time the dialog window opens. So if you change dialogs/myDialog.js or dialogs/myDialog.html, your changes will take effect the next time you open the dialog.
- However however, the above statement does not hold for code in separate scripts, such as controls. Let's say you create a control called colorPicker (assume colorPicker doesn't already exist in MM) in controls/colorPicker.js, and you're calling it from your dialog. If you make changes to controls/colorPicker.js, the changes won't take effect because those scripts are cached.
If you don't already have Refresh Skin Shortcut installed, I'd recommend it: https://www.mediamonkey.com/addons/brow ... -shortcut/
By default, clicking the button will refresh LESS (skin files). But if you right click the button, you can do a full window reload. You can change its default behavior by opening its settings panel in Tools > Addons.

Re: Beginner question about debugging scripts

Posted: Mon Mar 14, 2022 8:59 pm
by mms1234
thank you so much, this was very informative. I was missing the part about how to connect MediaMonkey to chrome, I thought developer mode did that. But now I see how that's done. Very cool to be able to debug that way. I've got a lot to catch up on, now I am atleast over the next hurdle. :)

thanks again!

Re: Beginner question about debugging scripts

Posted: Mon Mar 14, 2022 11:31 pm
by drakinite
No problem! Feel free to leave a reply or PM if you have more questions.

Turn on Developer Mode

Posted: Sun Mar 20, 2022 10:56 am
by spiky
Hi! can anyone clarify the instructions for switching on Developer Mode in MM5?

The documentation says "please turn on Developer Mode under Help -> About", but there is no such option under Help -> About. It just displays the "about" page, and that's all. No options of any kind, about anything at all, except you can click to see the license.

Re: Turn on Developer Mode

Posted: Sun Mar 20, 2022 11:03 am
by drakinite
spiky wrote: Sun Mar 20, 2022 10:56 am Hi! can anyone clarify the instructions for switching on Developer Mode in MM5?

The documentation says "please turn on Developer Mode under Help -> About", but there is no such option under Help -> About. It just displays the "about" page, and that's all. No options of any kind, about anything at all, except you can click to see the license.
Hi,
I've merged this topic with another which contains a detailed answer to your question. :slight_smile: TL;DR: Install a debug build.