Page 1 of 1

Play songs by hotkey based on Genre, Playlist, Mood, Tempo..

Posted: Fri Nov 04, 2005 9:39 am
by Steegy

Here's a simple script (the first vbs that I made) that adds hotkeys to MediaMonkey so you can let it play songs based on Genre, Playlist, Mood, ... very easily.

You can download it from ... s_v1.0.vbs

Just put it in the MediaMonkey\Scripts\Auto folder and (re)start MM.

Code: Select all

' MediaMonkey Script 
' NAME: Play Hotkeys v1.0 
'  Predefines shortcuts to start playing songs of a specific Genre, from a
'  specific Playlist, or with specific Song Information (Tempo, Mood, Quality, ...)
' AUTHOR: Steegy aka RC
' DATE  : 19.10.2005 
' NOTE: Idea taken from Pekes "Predefined Genre Script v1.0" 
' - If wanted, change defaults in the "Variable Configuration" section of this file
' - Copy script to MM directory scripts\auto 
' USE: 
' - Press key CTRL 0 ...5 (default) to start playing the wanted genre/playlist/...
' Variable Definition (Do Not Change) 

Dim EGenre
Dim Counter

' Variable Configuration (EDIT HERE IF YOU WANT)

'The code has some "sharp edges" (it's messy sometimes, especcially variable names), I'm sorry for that.

Sub AddItemsToMenu

'Change genres According to your needs
'(The number is the IconIndex value)
' Playlist    17 <= OK		==> Playlists
' "Notes"     14 <= OK		==> Song Information (Tempo, Mood, Quality, ...)
' Genre       58 <= OK		==> Genres
' Artist      60
' Rating star 64
'(The Y/N means Yes or No and sets the use of Shift, Crtl, Alt in the HotKey)

  AddItemToMenu("14|NYN|Rustig en Traag")
  AddItemToMenu("17|NYN|Zachte Trance")

End Sub

' MediaMonkey On Start Procedure 

Sub OnStartup 
Counter = 0

  SDB.UI.AddMenuItemSep SDB.UI.Menu_Edit,0,0

  Set EGenre = SDB.UI.addMenuItemSub(SDB.UI.Menu_Edit,0,0) 
  EGenre.caption = "Play Hotkeys" 
  EGenre.IconIndex = 58 
  EGenre.useScript = Script.ScriptPath 

End Sub 

Sub AddItemToMenu(Str_Item)
  Counter = Counter + 1

  Dim GenreA 
  Set GenreA = SDB.UI.AddMenuItem(EGenre,0,0) 
  GenreA.Caption = Right(Str_Item,Len(Str_Item)-7)
  GenreA.OnClickFunc = "PlayCategory" 
  GenreA.UseScript = Script.ScriptPath 
  GenreA.IconIndex = Left(Str_Item,2)
  GenreA.ShortCut = ShortCut(Str_Item)&Counter

End Sub

Function ShortCut(Caption)

  ShortCut = "" 
  If Mid(Caption,4,1)="Y" Then 
     ShortCut = ShortCut&"Shift+" 
  End if 
  If Mid(Caption,5,1)="Y" Then 
     ShortCut = ShortCut&"Ctrl+" 
  End if 
  If Mid(Caption,6,1)="Y" Then 
     ShortCut = ShortCut&"Alt+" 
  End if 

End Function

Sub PlayCategory(Item) 

  Select Case Item.IconIndex
    Case 58:
    Case 14:
    Case 17:
    Case Else:
      SDB.MessageBox "PlayHotkeys: The specified playlist doesn't exist!", mtError, Array(mbOk)
  End Select

End Sub

' Adding the specified category to the Now Playing playlist 

Sub PlayInfoInt(Name)

   Dim MyInfoNumber
   Set MyInfoNumber = SDB.Database.OpenSQL("SELECT Lists.ID FROM Lists WHERE TextData = '" & Name & "'")
   If Not MyInfoNumber.EOF Then
     Dim MySongNumber
     Set MySongNumber = SDB.Database.OpenSQL("SELECT AddSongInfoInt.IDSong FROM AddSongInfoInt WHERE AddSongInfoInt.IntData = " & MyInfoNumber.StringByIndex(0))
     While Not MySongNumber.EOF
       SDB.Player.PlaylistAddTrack(SDB.Database.QuerySongs("AND Songs.ID = " & MySongNumber.StringByIndex(0)).Item)
     SDB.MessageBox "PlayHotkeys: The specified song information doesn't exist!", mtError, Array(mbOk)
   End If

End Sub

Sub PlayPlaylist(Playlist)

   Dim MyPlaylist
   Set MyPlaylist = SDB.PlaylistByTitle(Playlist)
   If Not MyPlaylist.Title = "" Then
     SDB.MessageBox "PlayHotkeys: The specified playlist doesn't exist!", mtError, Array(mbOk)
   End If

End Sub

Sub PlayGenre(Genre) 

  Dim MyGenreNumber
  Set MyGenreNumber = SDB.Database.OpenSQL("SELECT Genres.IDGenre FROM Genres WHERE Genres.GenreName = '" & Genre & "'")

  If Not MyGenreNumber.EOF Then
    MyGenreNumber = MyGenreNumber.StringByIndex(0)
    Dim MyTrack
    Set MyTrack = SDB.Database.QuerySongs("AND Songs.Genre = " & MyGenreNumber)
    While Not MyTrack.EOF
    SDB.MessageBox "PlayHotkeys: The specified genre doesn't exist!", mtError, Array(mbOk)
  End If

End Sub 
Steegy (aka RC)

Posted: Mon Nov 07, 2005 9:28 am
by trixmoto
Nice script, thanks! :)

Posted: Sat Jul 15, 2006 8:37 am
by sasapuksic
Just what I was looking for ...

Works like magic with autoplaylists, AtiRemote Wonder II and RWkeyfactory Plugin!! MM is everything I ever wanted!! Thanks guys!!


Posted: Thu Sep 21, 2006 12:48 am
by salamat
Great script! But how can I change the genre to the one I use to play, like Jazz, progrock a.s.o.?

Posted: Thu Sep 21, 2006 5:08 am
by Steegy

To change the genre Trance to Jazz, change

Code: Select all


Code: Select all

These entries are "genres" because the number is 58 (genre).

I definately chould make this script easier to configure.


Nice script..

Posted: Wed Jan 03, 2007 9:49 pm
by tableguy
any way to add more HotKeys and Styles (sub-grene)?


Re: Play songs by hotkey based on Genre, Playlist, Mood, Tempo..

Posted: Mon May 31, 2010 4:12 pm
by nioflaz
Can someone explain this more to me as it might be exactly what i'm looking for. Basically for my A2 project I want to make a stereo that plays songs of a certain genre after selecting that genre on a control panel I'll make so you don't have to use the iPod after plugging it in. Will this program do exactly that? And, if you can suggest, how could I use this like would I download it to something? Thanks

Re: Play songs by hotkey based on Genre, Playlist, Mood, Tem

Posted: Sat Nov 26, 2011 4:28 am
by BerniPi

does this script work with MM3 or MM4? I would like to start Playlists with Hotkeys. The Script generates the menu and i can start a Playlist with the menu, but the hotkey Ctrl+0 doesn't work. Are there other scripts with this functionality or is it integrated in MM4?