Genre Shortcut Keys

Download and get help for different MediaMonkey Addons.

Moderators: Peke, Gurus

rk
Posts: 104
Joined: Mon Jul 25, 2005 2:18 am
Location: Germany

Post by rk » Fri Aug 26, 2005 3:57 am

Hey! I improved the script a bit to make the rating process faster ... nealy no mouse clicks needed to step through an album and rate the songs!!

Can anybody have a look onto the end of Sub EditRating? Do I have to release the memory again?

Code: Select all

'========================================================================== 
' 
' MediaMonkey Script 
' 
' NAME: Predefined RATING Script v1.2 
' 
' AUTHOR: Ralf K.
' DATE:   26.08.2005 
'
' NOTE:   Idea taken from Pekes "Predefined Genre Script v1.0"
' 
' INSTALL: 
' - If wanted, change constants in the beginning of this file
' - Copy script to MM directory scripts\auto
'
' USE:
' - Press key 0 ...5 to rate the currently selected song(s)
' - If no song is selected then currently playing song is rated
'
' REMARK: Rating process now can be done very fast without additional mouse clicks:
'   1) Start playing a list
'   2) Make sure no tracks are selected (otherwise they catch the rating)
'   3) Listen to track; wind forward if needed with '3' on numeric pad
'   4) Press 0 ..5 on normal keyboard for rating
'   5) Jump to next song with '9' an numeric pad
'   6) Continue with step 3)
' 
'========================================================================== 


'========================================================================== 
' Define some constants 
'========================================================================== 
'Set Value to TRUE/FALSE if you want to use HotKey modifiers
const Use_Shift = FALSE  'TRUE
const Use_Ctrl  = FALSE  'TRUE
const Use_Alt   = FALSE  'TRUE

'Icon to be used in the menu
const MenuIcon  = 64     '=yellow star

'========================================================================== 
' MediaMonkey on-start Procedure 
'========================================================================== 
Sub OnStartup 
' --------------
' Build the hotkey modifier
' --------------
  Dim HotKeyRing 
  HotKeyRing = ""

  If Use_Shift Then 
     HotKeyRing = HotKeyRing&"Shift+" 
  End if 
  If Use_Ctrl Then 
     HotKeyRing = HotKeyRing&"Ctrl+" 
  End if 
  If Use_Alt Then 
     HotKeyRing = HotKeyRing&"Alt+" 
  End if 

' ----------------
' Create a new edit menu entry
' ----------------
' first we make a separator
  SDB.UI.AddMenuItemSep SDB.UI.Menu_Edit, 0, 0 

' then we add the new menu
  Dim RatingMenu 
  Set RatingMenu       = SDB.UI.addMenuItemSub(SDB.UI.Menu_Edit,0,0) 
  RatingMenu.caption   = "Change Rating" 
  RatingMenu.IconIndex = MenuIcon
  RatingMenu.useScript = Script.ScriptPath 

' ----------------
' Create the sub menus
' ----------------
  Dim RatingSubmenu(5)
  Dim i
  
  for i = 0 to 5
    Set RatingSubmenu(i) = SDB.UI.AddMenuItem(RatingMenu,0,0)

    RatingSubmenu(i).Caption     = i & " Star"
    RatingSubmenu(i).OnClickFunc = "PredefinedRating" 
    RatingSubmenu(i).UseScript   = Script.ScriptPath 
    RatingSubmenu(i).IconIndex   = MenuIcon 
    RatingSubmenu(i).ShortCut    = HotKeyRing&i 
  Next
  
End Sub 

'========================================================================== 
' Helper and callback procedure 
'========================================================================== 
Sub EditRating(i_rating) 
  Dim songlist, song, i 

' ---------------
' First check which songs to alter
' ---------------
  If SDB.SelectedSongList.count > 0 Then 
    Set songlist = SDB.SelectedSongList
  elseif SDB.Player.CurrentSongIndex >= 0 then
    Set songlist = SDB.NewSongList 
    songlist.Add(SDB.Player.CurrentSong)
  else
    Result = SDB.MessageBox("No tracks selected!", mtError, Array(mbOk)) 
    Exit Sub 
  End If 

' ---------------
' Change the songs rating
' ---------------
  For i = 0 To songlist.count-1 
    Set song = songlist.Item(i) 
    song.Rating = i_rating 
    song.UpdateDB           'update MM database
    song.WriteTags          'write data to file tag
  Next 

' free memory again??
' songlist = nothing

End Sub 


Sub PredefinedRating(i_menuItem) 
'  Rating varies from 0 (= 0 stars) to 100 (= 5 stars)
'  So we multiply caption (= 0...5) with 20

   EditRating(Left(i_menuItem.Caption,1)*20) 
End Sub

onkel_enno
Posts: 2146
Joined: Fri Jan 14, 2005 1:45 am
Location: Germany
Contact:

Post by onkel_enno » Fri Aug 26, 2005 4:03 am

I think Songlist should be released automatically because it's a local Variable within the procedure.
But to be sure you could release it with "Set SongList = Nothing "
SansaMonkey - for SanDisk Sansa and Rockbox Users

Please no PMs for Questions which should be asked in the Forum. Thx

rk
Posts: 104
Joined: Mon Jul 25, 2005 2:18 am
Location: Germany

Post by rk » Fri Aug 26, 2005 4:12 am

onkel_enno wrote:... you could release it with "Set SongList = Nothing "
But in the case where songlist points to the currently selected songs, I do not have acquired additional memory. Will I destroy something if I release it in that case?

onkel_enno
Posts: 2146
Joined: Fri Jan 14, 2005 1:45 am
Location: Germany
Contact:

Post by onkel_enno » Fri Aug 26, 2005 4:16 am

Good Question. I don't know. But I don't think that you will destroy s.th.

Code: Select all

Set SDB = CreateObject( "SongsDB.SDBApplication")
Set SDB = Nothing
... doesn't destroy MediaMonkey too.
SansaMonkey - for SanDisk Sansa and Rockbox Users

Please no PMs for Questions which should be asked in the Forum. Thx

baker

Post by baker » Tue Oct 11, 2005 11:01 am

This is a great script. I've been using it to update not only genres but year and custom fields and. There's only one problem though.. Is there anyway to tell MM not to use these hotkeys when modifying a filename? For example, if I want to change a filename to "Beatles - Sgt Pepper", I can't do it unless I go into Properties because I have the 'B' key assigned to 'Blues'. Mucho gracias.

Peke
Posts: 11129
Joined: Tue Jun 10, 2003 7:21 pm
Location: Serbia
Contact:

Post by Peke » Tue Oct 11, 2005 5:15 pm

const Use_Shift = FALSE 'TRUE
const Use_Ctrl = FALSE 'TRUE
const Use_Alt = FALSE 'TRUE

Change FALSE to TRUE and you Will Get 8 Different Combinations of Hotkeys +Number
Best regards,
Pavle
MediaMonkey lead QA/Tech Support guru
Admin of Free MediaMonkey addon Site HappyMonkeying
Image
Image
How to add Images to forum

baker

Post by baker » Tue Oct 11, 2005 9:20 pm

AH yes..but I was wondering if there is a way to not use those keys and still be able to enter text in the filename. I'm all thumbs when it comes to key combinations :roll:

Peke
Posts: 11129
Joined: Tue Jun 10, 2003 7:21 pm
Location: Serbia
Contact:

Post by Peke » Tue Oct 11, 2005 9:34 pm

Not That I know of.
Best regards,
Pavle
MediaMonkey lead QA/Tech Support guru
Admin of Free MediaMonkey addon Site HappyMonkeying
Image
Image
How to add Images to forum

baker

Post by baker » Wed Oct 12, 2005 10:26 am

OK. Then hows about a 'Master' hotkey that turns the rest of the hotkeys on and off?

gab
Posts: 328
Joined: Tue Oct 11, 2005 1:20 pm

Post by gab » Sun Oct 16, 2005 3:34 pm

First, I know nothing about scripts other than they allow you to customize the appication. I'd like to try the rating script however I don't know what to do with the code. I've created a text file, named it "Predefined Rating.vbs", and copied all the code into that file. Now, when I open MM I get run-time error and the Ctrl+Alt+# key does not work.

Would you mind giving a (not too smart) newbie some help with this? Sincerely appreciated.

trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Barton, UK
Contact:

Post by trixmoto » Mon Oct 17, 2005 3:43 am

Where did you put the.vbs file gab?

When you say "Ctrl+Alt+#", have you changed the variables so that Ctrl and Alt are true?
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.
Send me BTC: 34VQPVsf9mCeR4nfhFvvBYZqQ7LkqNZ8Mn
Send me LTC: 3P1mzrfbyscdhbxRpXLgKz7tufGAU3SrEG
Send me DOGE: 9xPpYSqgF7P5yQiqvE1VqWb4UjxVCCLFJ6
Check out these great cryptocurrency faucets... BTC / LTC / DOGE

gab
Posts: 328
Joined: Tue Oct 11, 2005 1:20 pm

Post by gab » Mon Oct 17, 2005 6:17 am

I placed the file in Scripts\Auto. I didn't change anything (simply copied the code into the file). Also, I don't know how to change anything in the script :oops:

trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Barton, UK
Contact:

Post by trixmoto » Mon Oct 17, 2005 6:25 am

Which runtime error do you get?

To change the rating you just press the number key, no need for Ctrl or Alt. Select the tracks you want, and hit key 1-5. You can change the script to add Ctrl, Alt and/or Shift if you want to.
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.
Send me BTC: 34VQPVsf9mCeR4nfhFvvBYZqQ7LkqNZ8Mn
Send me LTC: 3P1mzrfbyscdhbxRpXLgKz7tufGAU3SrEG
Send me DOGE: 9xPpYSqgF7P5yQiqvE1VqWb4UjxVCCLFJ6
Check out these great cryptocurrency faucets... BTC / LTC / DOGE

gab
Posts: 328
Joined: Tue Oct 11, 2005 1:20 pm

Post by gab » Wed Oct 19, 2005 6:16 am

Hitting the number key doesn't work either. I don't know which run-time error i received. I'll check tonight when I get home (I've been traveling on business the last couple of days)

limex
Posts: 64
Joined: Sat Oct 22, 2005 10:29 am
Location: Vienna / Austria

Rating with half stars

Post by limex » Sun Jan 22, 2006 5:40 pm

Hi,

the script of rk is great ... greetings to you, my german speaking neighbor. :D

I "pimped" the script to meet my needs. I am used to assign also 1/2 stars. So I changed the script to use the buttons 1 to 0 to assign the full band of stars. 1 = 1/2 star, 2 = 1 star, 3 = 1 1/2 stars, ... 0 = 5 stars.

I mentioned in the comment, that rk is the original author. This brings all the fame to rk :wink:

I change the creation of the menu from loop to sequential adding because I was hoping to process the caption like rk in his script.
It seems to me that my german WinXP environment doesn't like to cast the "." as a comma. So I used the Shortcut property.

Code: Select all

'========================================================================== 
' 
' MediaMonkey Script 
' 
' NAME: Predefined RATING Script v1.3 
' 
' AUTHOR: LIMEX
' DATE: 22.01.2006
'
' ORIGINAL AUTHOR: Ralf K. 
'DATE:   26.08.2005 
' 
' NOTE:   Idea taken from Pekes "Predefined Genre Script v1.0".
'					LIMEX: I changed to use buttons 1-0 instead of 1-5 in order to assign also 1/2 stars.
' 
' INSTALL: 
' - If wanted, change constants in the beginning of this file 
' - Copy script to MM directory scripts\auto 
' 
' USE: 
' - Press key 1...0 to rate the currently selected song(s) 
' - If no song is selected then currently playing song is rated 
' 
' REMARK: Rating process now can be done very fast without additional mouse clicks: 
'   1) Start playing a list 
'   2) Make sure no tracks are selected (otherwise they catch the rating) 
'   3) Listen to track; wind forward if needed with '3' on numeric pad 
'   4) Press 1..0 on normal keyboard for rating 
'   5) Jump to next song with '9' an numeric pad 
'   6) Continue with step 3) 
' 
'========================================================================== 


'========================================================================== 
' Define some constants 
'========================================================================== 
'Set Value to TRUE/FALSE if you want to use HotKey modifiers 
const Use_Shift = FALSE  'TRUE 
const Use_Ctrl  = FALSE  'TRUE
const Use_Alt   = FALSE  'TRUE 

'Icon to be used in the menu 
const MenuIcon  = 64     '=yellow star 

'========================================================================== 
' MediaMonkey on-start Procedure 
'========================================================================== 
Sub OnStartup 
' -------------- 
' Build the hotkey modifier 
' -------------- 
  Dim HotKeyRing 
  HotKeyRing = "" 

  If Use_Shift Then 
     HotKeyRing = HotKeyRing&"Shift+" 
  End if 
  If Use_Ctrl Then 
     HotKeyRing = HotKeyRing&"Ctrl+" 
  End if 
  If Use_Alt Then 
     HotKeyRing = HotKeyRing&"Alt+" 
  End if 

' ---------------- 
' Create a new edit menu entry 
' ---------------- 
' first we make a separator 
  SDB.UI.AddMenuItemSep SDB.UI.Menu_Edit, 0, 0 

' then we add the new menu 
  Dim RatingMenu 
  Set RatingMenu       = SDB.UI.addMenuItemSub(SDB.UI.Menu_Edit,0,0) 
  RatingMenu.caption   = "Change Rating" 
  RatingMenu.IconIndex = MenuIcon 
  RatingMenu.useScript = Script.ScriptPath 

' ---------------- 
' Create the sub menus 
' ---------------- 
  Dim RatingSubmenu(10) 
  
  Set RatingSubmenu(0) = SDB.UI.AddMenuItem(RatingMenu,0,0) 
	RatingSubmenu(0).Caption     = "0.5 Star" 
  RatingSubmenu(0).OnClickFunc = "PredefinedRating" 
  RatingSubmenu(0).UseScript   = Script.ScriptPath 
  RatingSubmenu(0).IconIndex   = MenuIcon 
  RatingSubmenu(0).ShortCut    = HotKeyRing&"1"
  
  Set RatingSubmenu(1) = SDB.UI.AddMenuItem(RatingMenu,0,0) 
	RatingSubmenu(1).Caption     = "1.0 Star" 
  RatingSubmenu(1).OnClickFunc = "PredefinedRating" 
  RatingSubmenu(1).UseScript   = Script.ScriptPath 
  RatingSubmenu(1).IconIndex   = MenuIcon 
  RatingSubmenu(1).ShortCut    = HotKeyRing&"2"
  
  Set RatingSubmenu(2) = SDB.UI.AddMenuItem(RatingMenu,0,0) 
	RatingSubmenu(2).Caption     = "1.5 Star" 
  RatingSubmenu(2).OnClickFunc = "PredefinedRating" 
  RatingSubmenu(2).UseScript   = Script.ScriptPath 
  RatingSubmenu(2).IconIndex   = MenuIcon 
  RatingSubmenu(2).ShortCut    = HotKeyRing&"3"
  
  Set RatingSubmenu(3) = SDB.UI.AddMenuItem(RatingMenu,0,0) 
	RatingSubmenu(3).Caption     = "2.0 Star" 
  RatingSubmenu(3).OnClickFunc = "PredefinedRating" 
  RatingSubmenu(3).UseScript   = Script.ScriptPath 
  RatingSubmenu(3).IconIndex   = MenuIcon 
  RatingSubmenu(3).ShortCut    = HotKeyRing&"4"
  
  Set RatingSubmenu(4) = SDB.UI.AddMenuItem(RatingMenu,0,0) 
	RatingSubmenu(4).Caption     = "2.5 Star" 
  RatingSubmenu(4).OnClickFunc = "PredefinedRating" 
  RatingSubmenu(4).UseScript   = Script.ScriptPath 
  RatingSubmenu(4).IconIndex   = MenuIcon 
  RatingSubmenu(4).ShortCut    = HotKeyRing&"5"
  
  Set RatingSubmenu(5) = SDB.UI.AddMenuItem(RatingMenu,0,0) 
	RatingSubmenu(5).Caption     = "3.0 Star" 
  RatingSubmenu(5).OnClickFunc = "PredefinedRating" 
  RatingSubmenu(5).UseScript   = Script.ScriptPath 
  RatingSubmenu(5).IconIndex   = MenuIcon 
  RatingSubmenu(5).ShortCut    = HotKeyRing&"6"
  
  Set RatingSubmenu(6) = SDB.UI.AddMenuItem(RatingMenu,0,0) 
	RatingSubmenu(6).Caption     = "3.5 Star" 
  RatingSubmenu(6).OnClickFunc = "PredefinedRating" 
  RatingSubmenu(6).UseScript   = Script.ScriptPath 
  RatingSubmenu(6).IconIndex   = MenuIcon 
  RatingSubmenu(6).ShortCut    = HotKeyRing&"7"
  
  Set RatingSubmenu(7) = SDB.UI.AddMenuItem(RatingMenu,0,0) 
	RatingSubmenu(7).Caption     = "4.0 Star" 
  RatingSubmenu(7).OnClickFunc = "PredefinedRating" 
  RatingSubmenu(7).UseScript   = Script.ScriptPath 
  RatingSubmenu(7).IconIndex   = MenuIcon 
  RatingSubmenu(7).ShortCut    = HotKeyRing&"8"
  
  Set RatingSubmenu(8) = SDB.UI.AddMenuItem(RatingMenu,0,0) 
	RatingSubmenu(8).Caption     = "4.5 Star" 
  RatingSubmenu(8).OnClickFunc = "PredefinedRating" 
  RatingSubmenu(8).UseScript   = Script.ScriptPath 
  RatingSubmenu(8).IconIndex   = MenuIcon 
  RatingSubmenu(8).ShortCut    = HotKeyRing&"9"
  
  Set RatingSubmenu(9) = SDB.UI.AddMenuItem(RatingMenu,0,0) 
	RatingSubmenu(9).Caption     = "5.0 Star" 
  RatingSubmenu(9).OnClickFunc = "PredefinedRating" 
  RatingSubmenu(9).UseScript   = Script.ScriptPath 
  RatingSubmenu(9).IconIndex   = MenuIcon 
  RatingSubmenu(9).ShortCut    = HotKeyRing&"0"
  
End Sub 

'========================================================================== 
' Helper and callback procedure 
'========================================================================== 
Sub EditRating(i_rating) 
  Dim songlist, song, i 

' --------------- 
' First check which songs to alter 
' --------------- 
  If SDB.SelectedSongList.count > 0 Then 
    Set songlist = SDB.SelectedSongList 
  elseif SDB.Player.CurrentSongIndex >= 0 then 
    Set songlist = SDB.NewSongList 
    songlist.Add(SDB.Player.CurrentSong) 
  else 
    Result = SDB.MessageBox("No tracks selected!", mtError, Array(mbOk)) 
    Exit Sub 
  End If 

' --------------- 
' Change the songs rating 
' --------------- 
  For i = 0 To songlist.count-1 
    Set song = songlist.Item(i) 
    song.Rating = i_rating 
    song.UpdateDB           'update MM database 
    song.WriteTags          'write data to file tag 
  Next 

' free memory again?? 
' songlist = nothing 

End Sub 


Sub PredefinedRating(i_menuItem) 
'  Rating varies from 0 (= 0 stars) to 100 (= 5 stars) 
'  So we multiply caption (= 1...0) with 10 

	Dim i_rating
	i_rating = Right(i_menuItem.ShortCut,1)
	
	If i_rating = 0 Then
		i_rating = 100
	Else	
		i_rating = i_rating*10
	End If 
		
   EditRating(i_rating) 
End Sub 

Post Reply