Few questions about scripting

This forum is for questions / discussions regarding development of addons / tweaks for MediaMonkey for Windows 4.

Moderators: Gurus, Addon Administrators

kacso
Posts: 18
Joined: Sat Feb 08, 2014 3:25 pm

Few questions about scripting

Post by kacso »

Hi, I got few question about scripting.

1. How can I use some letter or number as shortcut to my script and can I use shortcut eg. ctrl + left click?

2. How can I delete song from song list? I try using songlist.item.delete and index of track in list but every time I got an error.

3. Is it possible in listbox detect double click on some item?

4. Is it possible to detect which song is selected in nowplaying list?

5. Is it possible to add my option (shortcut to script or subroutine in script) in list which opens when clicked with right click on some track?

6. Is it possible to use shortcut in form? Something like, I select some item in listbox and using shortcut (eg. Alt + a) press some button in form. I now for default option and I'm using it when "Enter" is pressed.

Hope that I will have more luck then last time I posted her :D
kacso
Posts: 18
Joined: Sat Feb 08, 2014 3:25 pm

Re: Few questions about scripting

Post by kacso »

New question!

7. Problem with MoveTrack subroutine (in Player class)!
Everything works fine except when track should be moved to last position. In subroutine description (http://www.mediamonkey.com/wiki/index.p ... :MoveTrack) says that if I want to move track to last position I should put NULL as before track.
I tried with this code:

Code: Select all

queuePlaylist.MoveTrack objSongdata, NULL
but with him I get error: type mismatch.

Please help!
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Re: Few questions about scripting

Post by trixmoto »

Well that's a lot of questions, which might be better discussed in different threads, but I'll do my best to get you started...

1. If your script has a toolbar button or menu item then you can use ShortCut property. You can also setup global hotkeys in the options, you might be able to write one into the Scripts.ini file using SDB.IniFile and then using Apply.

2. What is the error that you're getting? Note that the Delete method is zero indexed, so the id of the first item in the list is 0 and the id of the last item would be Count-1.

3. There's an double click event for all of the UI.Common items... OnDblClick.

4. If you're in the Now Playing list at the moment then selected songs are held in SelectedSongList.

5. Yes, you first grab the Manu_Pop_Tracklist object then you can add the menu item using AddMenuItem.

6. Yes, in the button Caption you put an "&" before the character you want to be the accelerator. Or at least I think that works, if memory serves. So "&Ok" means that Alt+O would click the "Ok" button - the "O" is also underlined to reflect this.

7. In VBScript I think you would use "Nothing" as the keyword for a null object. I've not tried it in this case, but worth a shot.

I hope this helps :)
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
kacso
Posts: 18
Joined: Sat Feb 08, 2014 3:25 pm

Re: Few questions about scripting

Post by kacso »

I now that it's a lot questions but it seems me as bed idea to open so many threads...

1. I don't use menu items so it goes off. I don't now how I did't tried with global hotkeys, it works thanks :D. I tried and writing in Script.ini file but it didn't work :-?
Is it possible to call specific subroutine with hotkeys or shortcuts?
2. Error is "Object required: 'objSongData'" and it's few lines before calling "Delete" but in that line can't be a problem because everything works fine when Delete is not called. That line is if statement where I use Regexp comparison of strings. It's not big problem if it won't work, I manage to avoid Delete using extra list but I think that with Delete would be faster.
3. Tried this now but it doesn't work, I don't now why... This is part of code:

Code: Select all

Set LB = SDB.UI.NewListBox(Form)
	LB.Common.SetRect 5, 30, 485, 360
	Script.RegisterEvent LB, "OnDblClick", "PlaySong"
4. & 5. I will look this more detail latter but it seems workable, thanks :D
6. It works, thanks!
7. Tried now with "Nothing" but get an Catastrophic error if it's written in function call and "Object variable not set" error if I call with newSongData object to which I assign Nothing before. In description says that it should be NULL, I don't no :(

Thanks for answering, it was helpful :)
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Re: Few questions about scripting

Post by trixmoto »

1. Yeah, I've found that sometimes changes are picked up and sometimes they're not, depending on what you're trying to do. If you're writing it during the installation of the package then you can also set a property in "Install.ini" to trigger a restart, so that might then pick up the changes properly.

2. Hmmm, I'm not sure then, sorry.

3. You need to register the event to "LB.Common" instead of "LB", then it should work.

4-6. Great.

7. I don't know then. I've just done a search and found that I've had this problem before! (see here). It looks like I gave up and actually tooks all the tracks out of the playlist and then rebuilt a new one, because I was trying to randomise the whole list. Have you tried deleting the item from the playlist and then adding it back in again? I would have thought this would move it to the end.
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
kacso
Posts: 18
Joined: Sat Feb 08, 2014 3:25 pm

Re: Few questions about scripting

Post by kacso »

3. Now it works, thanks!

7. In meanwhile I resolve this problem. I'm moving tracks only for one position up or down so I manage to avoid this problem by moving last track one position up.

Thanks for help! :)

Can you take a look on this too...
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Re: Few questions about scripting

Post by trixmoto »

Great. I did read that post earlier, but I didn't really have an idea. I have replied now, but I don't know if it's any use.
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Post Reply