- Played
- FileModified
- TrackModified
- Added

Shortcut menu to the options:

in the Options you can speed up the the script by creating indexes on the affected fields.
The Sort Order can be adjusted to fit your needs. You can also set a Filter per Node.

Shortcut menu to set the Sort Order:

Enjoy!
/Bex
For information only. You can download the installer package and read the installation instructions at the bottom of this post.
- Code: Select all
' MediaMonkey Script
'
' NAME: Last
' VERSION: 1.5
' LAST UPDATED: 2009-07-14
' AUTHOR: Bex
' DATE : 2006-11-03
'
' MANUAL INSTALL:
' 1) Goto "Mediamonkey\Scripts\Auto" folder. Right click and create a txt file.
' 2) Name it Last.vbs (Make sure it's not named Last.vbs.txt)
' 3) Copy all this content into the file and save it.
' 4) (Re)start MediaMonkey
'
' This script creates a "Last 100 Tracks..."-Node whith four subnodes: "Played", "FileModified","TrackModified" and "Added"
'
'///////////////////////////////////////////////////////////////////////////////////
Option Explicit
Dim UI : Set UI = SDB.UI
Dim DB : Set DB = SDB.Database
Dim INI : Set INI = SDB.IniFile
Dim Tree : Set Tree = SDB.MainTree
Dim Window : Set Window = SDB.MainTracksWindow
Dim Filters(),FilterSQL
Const ScriptName = "Last..."
Const ReqMMVersion = "3.1.0"
Const ReqMMBuild = 1256
Dim OrderByArray(2)
OrderByArray(0)="Ascending"
OrderByArray(1)="Descending"
OrderByArray(2)="Special Order"
Function InvalidMM()
If SDB.VersionString < ReqMMVersion Then
SDB.MessageBox "This version of "& ScriptName &" is only compatible with MediaMonkey "& ReqMMVersion &"."& ReqMMBuild &" and later."& VbNewLine &_
"Please Update your version of MediaMonkey. You might need to download from the Beta Forum to get the required version."& VbNewLine &_
"The script will be disabled.", mtWarning, Array(mbOk)
InvalidMM=True
Exit Function
End If
InvalidMM=False
End Function
Sub Install()
If InvalidMM Then Exit Sub
Script.UnRegisterAllEvents
SDB.RefreshScriptItems
Call HideAndSetMenusToNothing("LastSettingsMnu")
Call HideAndSetMenusToNothing("PlayedMnu")
Call HideAndSetMenusToNothing("FileModifiedMnu")
Call HideAndSetMenusToNothing("TrackModifiedMnu")
Call HideAndSetMenusToNothing("AddedMnu")
Call onStartup()
End Sub
Sub HideAndSetMenusToNothing(Name)
If Not SDB.Objects(Name) Is Nothing Then
SDB.Objects(Name).Visible=False
Set SDB.Objects(Name) = Nothing
End If
End Sub
Sub OnStartup
If InvalidMM Then Exit Sub
Dim FirstUseText
'Delete all old INI entries
INI.DeleteSection("Last")
If Not INI.ValueExists("Last100","FirstUse") Then INI.BoolValue("Last100","FirstUse") = True
If Not INI.ValueExists("Last100","TopLimit") Then INI.IntValue("Last100","TopLimit") = 100
If Not INI.ValueExists("Last100","Played") Then INI.StringValue("Last100","Played") = "0.0"
If Not INI.ValueExists("Last100","Modified") Then INI.StringValue("Last100","Modified") = "0.0"
If Not INI.ValueExists("Last100","TrackModified") Then INI.StringValue("Last100","TrackModified") = "0.0"
If Not INI.ValueExists("Last100","Added") Then INI.StringValue("Last100","Added") = "0.0"
If Not INI.ValueExists("Last100","PlayedDrd") Then INI.IntValue("Last100","PlayedDrd") = 1
If Not INI.ValueExists("Last100","FileModifiedDrd") Then INI.IntValue("Last100","FileModifiedDrd") = 1
If Not INI.ValueExists("Last100","TrackModifiedDrd") Then INI.IntValue("Last100","TrackModifiedDrd") = 1
If Not INI.ValueExists("Last100","AddedDrd") Then INI.IntValue("Last100","AddedDrd") = 2
If Not INI.ValueExists("Last100","OrderByInCaption") Then INI.BoolValue("Last100","OrderByInCaption")= True
Ini.StringValue("Last100","OptSheet")=UI.AddOptionSheet("Last... Settings",Script.ScriptPath,"InitSheet","SaveSheet",-3)
Call CreateMnu(UI.Menu_Pop_Tree,1,1,"Last "& INI.IntValue("Last100","TopLimit") &" Tracks... Settings","LastSettings","LastSettingsMnu","",27,True,False)
Call CreateSortOrderMenus("Played Sort Order",OrderByArray,"PlayedMnu","PlayedDrd")
Call CreateSortOrderMenus("FileModified Sort Order",OrderByArray,"FileModifiedMnu","FileModifiedDrd")
Call CreateSortOrderMenus("TrackModified Sort Order",OrderByArray,"TrackModifiedMnu","TrackModifiedDrd")
Call CreateSortOrderMenus("Added Sort Order",OrderByArray,"AddedMnu","AddedDrd")
If INI.BoolValue("Last100","FirstUse") Then FirstUseText=" (Press F2 to change)" Else FirstUseText=""
Dim Node : Set Node = CreateNode(Tree.Node_Library,"Last "& INI.IntValue("Last100","TopLimit") &" Tracks..."& FirstUseText,1,49,"","CreateSubNodes","LastNode","LastNode",True)
Script.RegisterEvent Node,"OnCanEditNode", "OnCanEditNode"
Script.RegisterEvent Node,"OnNodeEditText","EditTopLimitText"
Script.RegisterEvent Node,"OnNodeEdited", "EditTopLimit"
Call Script.RegisterEvent(SDB,"OnChangedSelection","SetMnuVisibility")
Call Script.RegisterEvent(SDB,"OnShutdown","PerformTasksOnShutdown")
End Sub
Sub CreateSubNodes(Node)
Node.HasChildren=False
Call CreateNode(Node,GetNodeCaption("Played"),3,10,"AddTracks","","PlayedNode","PlayedNode",False)
Call CreateNode(Node,GetNodeCaption("FileModified"),3,10,"AddTracks","","FileModifiedNode","FileModifiedNode",False)
Call CreateNode(Node,GetNodeCaption("TrackModified"),3,10,"AddTracks","","TrackModifiedNode","TrackModifiedNode",False)
Call CreateNode(Node,GetNodeCaption("Added"),3,10,"AddTracks","","AddedNode","AddedNode",False)
End Sub
Function GetNodeCaption(Txt)
If INI.BoolValue("Last100","OrderByInCaption") And INI.BoolValue("Last100","FilterInCaption") Then
GetNodeCaption=Txt & " (" & OrderByArray(INI.IntValue("Last100",Txt & "Drd")) & ")" & " (" & GetFilterName(INI.StringValue("Last100",Txt & "Filter")) & ")"
ElseIf INI.BoolValue("Last100","OrderByInCaption") Then
GetNodeCaption=Txt & " (" & OrderByArray(INI.IntValue("Last100",Txt & "Drd")) & ")"
ElseIf INI.BoolValue("Last100","FilterInCaption") Then
GetNodeCaption=Txt & " (" & GetFilterName(INI.StringValue("Last100",Txt & "Filter")) & ")"
Else
GetNodeCaption=Txt
End If
End Function
Sub PerformTasksOnShutdown
Script.UnRegisterAllEvents
End Sub
Sub InitSheet(Sheet)
Dim txt,Gbx
txt="To make the script faster, Much Faster, you can create indexes on the affected fields in" & VbNewLine &_
"the databse. This will also speed up some Searches and Auto-Playlists using the fields." & VbNewLine &_
"The affected fields are LastTimePlayed, FileModified, TrackModified and DateAdded." & VbNewLine & VbNewLine &_
"However, it can make some other operations slightly slower. (E.g. Adding or Modifying tracks)" & VbNewLine &_
"If you encounter any unwanted side effetcs simply remove the indexes."
Set Gbx=CreateGbx(Sheet,10, 10,470,160,"Information: ")
Call CreateLbl(Gbx, 10, 18,100, 20,txt,"",True,False)
Call CreateBtn(Gbx, 120,110,100, 35,"","Create Indexes","CreateIdxBtn","OnCreateIdx","","","",True,True)
Call CreateBtn(Gbx, 245,110,100, 35,"","Remove Indexes","RemoveIdxBtn","OnRemoveIdx","","","",True,True)
txt="Set the sort order of the tracks when they are added to the main window." & VbNewLine &_
"Special Order means: IDFolder DESC, DiscNumber, TrackNumber, SongPath" & VbNewLine &_
"You can also set a Filter per node if you wish."
Set Gbx=CreateGbx(Sheet,10,180,470,235," Sort Order && Filters: ")
Call CreateLbl(Gbx, 10, 18,100, 20,txt,"",True,False)
Call CreateLbl(Gbx, 140, 70,100, 20,"Sort Order:","",True,True)
Call CreateLbl(Gbx, 260, 70,100, 20,"Filter:","",True,True)
Call CreateFiltersArray()
Call CreateLbl(Gbx, 10, 93,100, 20,"Played Node: ","",True,False)
Call CreateDrd(Gbx, 130, 90,100, 20,"PlayedDrd","",INI.IntValue("Last100","PlayedDrd"),"",OrderByArray,True,True)
Call CreateDrd(Gbx, 250, 90,200, 20,"PlayedFilterDrd","",GetFiltersArrayID(INI.StringValue("Last100","PlayedFilter"),Filters),"",Filters,True,True)
Call CreateLbl(Gbx, 10,118,100, 20,"FileModified Node: ","",True,False)
Call CreateDrd(Gbx, 130,115,100, 20,"FileModifiedDrd","",INI.IntValue("Last100","FileModifiedDrd"),"",OrderByArray,True,True)
Call CreateDrd(Gbx, 250,115,200, 20,"FileModifiedFilterDrd","",GetFiltersArrayID(INI.StringValue("Last100","FileModifiedFilter"),Filters),"",Filters,True,True)
Call CreateLbl(Gbx, 10,143,100, 20,"TrackModified Node: ","",True,False)
Call CreateDrd(Gbx, 130,140,100, 20,"TrackModifiedDrd","",INI.IntValue("Last100","TrackModifiedDrd"),"",OrderByArray,True,True)
Call CreateDrd(Gbx, 250,140,200, 20,"TrackModifiedFilterDrd","",GetFiltersArrayID(INI.StringValue("Last100","TrackModifiedFilter"),Filters),"",Filters,True,True)
Call CreateLbl(Gbx, 10,168,100, 20,"Added Node: ","",True,False)
Call CreateDrd(Gbx, 130,165,100, 20,"AddedDrd","",INI.IntValue("Last100","AddedDrd"),"",OrderByArray,True,True)
Call CreateDrd(Gbx, 250,165,200, 20,"AddedFilterDrd","",GetFiltersArrayID(INI.StringValue("Last100","AddedFilter"),Filters),"",Filters,True,True)
Call CreateCbx(Gbx, 10,200,250, 20,"Display the Sort Order in the Node Name","OrderByInCaptionCbx","",INI.BoolValue("Last100","OrderByInCaption"),True,True,"")
Call CreateCbx(Gbx, 250,200,250, 20,"Display the Filter in the Node Name","FilterInCaptionCbx","",INI.BoolValue("Last100","FilterInCaption"),True,True,"")
End Sub
Sub SaveSheet(Sheet)
INI.IntValue("Last100","PlayedDrd") =Sheet.Common.ChildControl("PlayedDrd").ItemIndex
INI.IntValue("Last100","FileModifiedDrd") =Sheet.Common.ChildControl("FileModifiedDrd").ItemIndex
INI.IntValue("Last100","TrackModifiedDrd") =Sheet.Common.ChildControl("TrackModifiedDrd").ItemIndex
INI.IntValue("Last100","AddedDrd") =Sheet.Common.ChildControl("AddedDrd").ItemIndex
If INI.StringValue("Last100","PlayedFilter") <>GetFilterID(Sheet.Common.ChildControl("PlayedFilterDrd").Text) Then INI.StringValue("Last100","Played") = "0.0"
If INI.StringValue("Last100","FileModifiedFilter") <>GetFilterID(Sheet.Common.ChildControl("FileModifiedFilterDrd").Text) Then INI.StringValue("Last100","Modified") = "0.0"
If INI.StringValue("Last100","TrackModifiedFilter")<>GetFilterID(Sheet.Common.ChildControl("TrackModifiedFilterDrd").Text) Then INI.StringValue("Last100","TrackModified") = "0.0"
If INI.StringValue("Last100","AddedFilter") <>GetFilterID(Sheet.Common.ChildControl("AddedFilterDrd").Text) Then INI.StringValue("Last100","Added") = "0.0"
INI.StringValue("Last100","PlayedFilter") =GetFilterID(Sheet.Common.ChildControl("PlayedFilterDrd").Text)
INI.StringValue("Last100","FileModifiedFilter") =GetFilterID(Sheet.Common.ChildControl("FileModifiedFilterDrd").Text)
INI.StringValue("Last100","TrackModifiedFilter")=GetFilterID(Sheet.Common.ChildControl("TrackModifiedFilterDrd").Text)
INI.StringValue("Last100","AddedFilter") =GetFilterID(Sheet.Common.ChildControl("AddedFilterDrd").Text)
INI.BoolValue("Last100","OrderByInCaption") =Sheet.Common.ChildControl("OrderByInCaptionCbx").Checked
INI.BoolValue("Last100","FilterInCaption") =Sheet.Common.ChildControl("FilterInCaptionCbx").Checked
SDB.Objects("PlayedNode").Caption=GetNodeCaption("Played")
SDB.Objects("FileModifiedNode").Caption=GetNodeCaption("FileModified")
SDB.Objects("TrackModifiedNode").Caption=GetNodeCaption("TrackModified")
SDB.Objects("AddedNode").Caption=GetNodeCaption("Added")
End Sub
Sub OnCreateIdx(Btn)
Dim bar : Set bar=SDB.Progress
bar.Text="Creating index 1 of 4. Please wait! (Can take a while if you have a big library.)"
DB.ExecSQL("CREATE INDEX IF NOT EXISTS idxSongsLastTimePlayed ON Songs (LastTimePlayed)")
bar.Text="Creating index 2 of 4. Please wait! (Can take a while if you have a big library.)"
DB.ExecSQL("CREATE INDEX IF NOT EXISTS idxSongsFileModified ON Songs (FileModified)")
bar.Text="Creating index 3 of 4. Please wait! (Can take a while if you have a big library.)"
DB.ExecSQL("CREATE INDEX IF NOT EXISTS idxSongsTrackModified ON Songs (TrackModified)")
bar.Text="Creating index 4 of 4. Please wait! (Can take a while if you have a big library.)"
DB.ExecSQL("CREATE INDEX IF NOT EXISTS idxSongsDateAdded ON Songs (DateAdded)")
Set bar=Nothing
Call SDB.MessageBox("Four indexes created." & VbNewLine, mtInformation, Array(mbOk))
End Sub
Sub OnRemoveIdx(Btn)
DB.ExecSQL("DROP INDEX IF EXISTS idxSongsLastTimePlayed")
DB.ExecSQL("DROP INDEX IF EXISTS idxSongsFileModified")
DB.ExecSQL("DROP INDEX IF EXISTS idxSongsTrackModified")
DB.ExecSQL("DROP INDEX IF EXISTS idxSongsDateAdded")
Call SDB.MessageBox("Four indexes deleted." & VbNewLine, mtInformation, Array(mbOk))
End Sub
Sub SetMnuVisibility()
If Not Tree.CurrentNode Is Nothing Then '<-- check a node is selected
SDB.Objects("LastSettingsMnu").Visible= Eval(Tree.CurrentNode.CustomData="LastNode")
SDB.Objects("PlayedMnu").Visible= Eval(Tree.CurrentNode.CustomData="PlayedNode")
SDB.Objects("FileModifiedMnu").Visible= Eval(Tree.CurrentNode.CustomData="FileModifiedNode")
SDB.Objects("TrackModifiedMnu").Visible=Eval(Tree.CurrentNode.CustomData="TrackModifiedNode")
SDB.Objects("AddedMnu").Visible= Eval(Tree.CurrentNode.CustomData="AddedNode")
End If
End Sub
Sub LastSettings(Mnu)
On Error Resume Next
If SDB.VersionBuild < 1209 Then
SDB.MessageBox "This shortcut only works in MediaMonkey 3.1.0.1256 and later."& VbNewLine &_
"Please Update your version of MediaMonkey. You might need"& VbNewLine &_
"to download from the Beta Forum to get the required version.", mtInformation, Array(mbOK)
Exit Sub
End If
On Error GoTo 0
Call UI.ShowOptions(Ini.StringValue("Last100","OptSheet"))
End Sub
Function OnCanEditNode(Node)
OnCanEditNode = True
End Function
Function EditTopLimitText(Node)
EditTopLimitText = INI.StringValue("Last100","TopLimit")
End Function
Sub EditTopLimit(Node,NewTopLimit)
If IsNumeric(NewTopLimit) Then
If Clng(NewTopLimit)<1 Then
SDB.MessageBox "1 Only type positive numbers, try again!", mtError, Array(mbOK)
Exit Sub
End If
Else
SDB.MessageBox "2 Only type positive numbers, try again!", mtError, Array(mbOK)
Exit Sub
End If
Node.Caption = "Last "& NewTopLimit &" Tracks..."
SDB.Objects("LastSettingsMnu").Caption="Last "& NewTopLimit &" Tracks... Settings"
INI.IntValue("Last100","TopLimit") = NewTopLimit
INI.StringValue("Last100","Played") = "0.0"
INI.StringValue("Last100","Modified") = "0.0"
INI.StringValue("Last100","TrackModified") = "0.0"
INI.StringValue("Last100","Added") = "0.0"
INI.BoolValue("Last100","FirstUse") = False
End Sub
Sub CheckSortOrderPlayedMnu(Mnu)
Call CheckSortOrder(Mnu,"Played")
End Sub
Sub CheckSortOrderFileModifiedMnu(Mnu)
Call CheckSortOrder(Mnu,"FileModified")
End Sub
Sub CheckSortOrderTrackModifiedMnu(Mnu)
Call CheckSortOrder(Mnu,"TrackModified")
End Sub
Sub CheckSortOrderAddedMnu(Mnu)
Call CheckSortOrder(Mnu,"Added")
End Sub
Sub CheckSortOrder(Mnu,Name)
Dim i,PrevSortOrder
PrevSortOrder=INI.IntValue("Last100",Name & "Drd")
For i=0 To UBound(OrderByArray)
SDB.Objects(Name & "Mnu" & i).Checked=False
Next
Mnu.Checked=True
For i=0 To UBound(OrderByArray)
If SDB.Objects(Name & "Mnu" & i).Checked Then INI.IntValue("Last100",Name & "Drd")=i
Next
SDB.Objects(Name & "Node").Caption=GetNodeCaption(Name)
If Not PrevSortOrder=INI.IntValue("Last100",Name & "Drd") Then AddTracks(SDB.Objects(Name & "Node"))
End Sub
Sub AddTracks(Node)
'A trick to reset any added sortorder to the tracks in Main window
SDB.MainTree.CurrentNode.NodeType = 12
SDB.MainTracksWindow.Refresh
SDB.MainTree.CurrentNode.NodeType = 255
'GetFilterSQL(PreSQL,FilterID,EndSQL,inikey,UsedWhere)
Dim sql,iter,i,MinValue
If Node.CustomData = "PlayedNode" Then sql=GetSql(GetFilterSQL("",INI.StringValue("Last100","PlayedFilter"),"AND","PlayedFilter","Played Node") & "PlayCounter>0 AND ","LastTimePlayed",INI.StringValue("Last100","Played"),INI.IntValue("Last100","PlayedDrd"))
If Node.CustomData = "FileModifiedNode" Then sql=GetSql(GetFilterSQL("",INI.StringValue("Last100","FileModifiedFilter"),"AND","PlayedFilter","FileModified Node") & "FileModified>DateAdded AND ","FileModified",INI.StringValue("Last100","Modified"),INI.IntValue("Last100","FileModifiedDrd"))
If Node.CustomData = "TrackModifiedNode" Then sql=GetSql(GetFilterSQL("",INI.StringValue("Last100","TrackModifiedFilter"),"AND","PlayedFilter","TrackModified Node") & "","TrackModified",INI.StringValue("Last100","TrackModified"),INI.IntValue("Last100","TrackModifiedDrd"))
If Node.CustomData = "AddedNode" Then sql=GetSql(GetFilterSQL("",INI.StringValue("Last100","AddedFilter"),"AND","PlayedFilter","Added Node") & "","DateAdded",INI.StringValue("Last100","Added"),INI.IntValue("Last100","AddedDrd"))
'msgbox sql
Set iter = SDB.Database.QuerySongs(sql)
Do While Not iter.EOF
i=i+1
Window.AddTrack(iter.item)
Select Case Node.CustomData
Case "PlayedNode"
If i=1 Then MinValue=iter.item.LastPlayed
If iter.item.LastPlayed <MinValue Then MinValue=iter.item.LastPlayed
Case "FileModifiedNode"
If i=1 Then MinValue=iter.item.FileModified
If iter.item.FileModified<MinValue Then MinValue=iter.item.FileModified
Case "TrackModifiedNode"
'If i=1 Then MinValue=iter.item.TrackModified
'If iter.item.TrackModified<MinValue Then MinValue=iter.item.TrackModified
Case "AddedNode"
If i=1 Then MinValue=iter.item.DateAdded
If iter.item.DateAdded<MinValue Then MinValue=iter.item.DateAdded
End Select
Iter.Next
Loop
'msgbox i
Window.FinishAdding
Set Iter=Nothing
If Node.CustomData = "PlayedNode" Then INI.StringValue("Last100","Played")=Replace(Cdbl(MinValue),",",".")
If Node.CustomData = "FileModifiedNode" Then INI.StringValue("Last100","Modified")=Replace(Cdbl(MinValue),",",".")
If Node.CustomData = "TrackModifiedNode" Then INI.StringValue("Last100","TrackModified")=DB.OpenSQL("SELECT MIN(TrackModified) FROM Songs WHERE TrackModified>="& INI.StringValue("Last100","TrackModified") &" ORDER BY TrackModified DESC LIMIT "& INI.IntValue("Last100","TopLimit")).StringByIndex(0)
If Node.CustomData = "AddedNode" Then INI.StringValue("Last100","Added")=Replace(Cdbl(MinValue),",",".")
'msgbox MinValue
End Sub
Function GetSql(SqlClause,SongField,MinValue,ItmIdx)
Dim limit : limit = INI.IntValue("Last100","TopLimit")
Select Case ItmIdx
Case 0
GetSql="Songs.ID IN (SELECT ID FROM Songs WHERE "& SqlClause & SongField &">="& MinValue &" ORDER BY LastTimePlayed DESC LIMIT "& limit &") "&_
"ORDER BY "& SongField
Case 1
GetSql=SqlClause & SongField &">="& MinValue &" ORDER BY "& SongField &" DESC LIMIT "& limit
Case 2
GetSql="Songs.ID IN (SELECT ID FROM Songs WHERE "& SqlClause & SongField &">="& MinValue &" ORDER BY "& SongField &" DESC LIMIT "& limit &") "&_
"ORDER BY IDFolder DESC, DiscNumber COLLATE NUMERICSTRING, TrackNumber COLLATE NUMERICSTRING, SongPath"
End Select
End Function
Function CreateNode(OnNode,Caption,NodePos,IconIndex,OnFillTracks,OnFillChildren,CustomData,ObjectName,HasChildren)
Set CreateNode = Tree.CreateNode
CreateNode.Caption = Caption
CreateNode.IconIndex = IconIndex
If Not OnFillTracks="" Then Script.RegisterEvent CreateNode, "OnFillTracks", OnFillTracks
If Not OnFillChildren="" Then Script.RegisterEvent CreateNode, "OnFillChildren", OnFillChildren
If Not CustomData ="" Then CreateNode.CustomData = CustomData
CreateNode.UseScript = Script.ScriptPath
Tree.AddNode OnNode, CreateNode, NodePos
If Not ObjectName="" Then SDB.Objects(ObjectName) = CreateNode
CreateNode.HasChildren = HasChildren
End Function
Function CreateMnu(OnMenu,InSection,ItemOrder,Caption,OnClickFunc,ObjectName,ShortCut,IconIndex,Enabled,Visible)
Set CreateMnu = UI.AddMenuItem(onMenu,InSection,ItemOrder)
CreateMnu.Caption = Caption
If Not OnClickFunc="" Then Script.RegisterEvent CreateMnu, "OnClick", OnClickFunc
If Not ShortCut="" Then CreateMnu.ShortCut = ShortCut
If Not IconIndex="" Then CreateMnu.IconIndex = IconIndex
CreateMnu.UseScript=Script.ScriptPath
CreateMnu.Enabled = Enabled
CreateMnu.Visible = Visible
If Not ObjectName="" Then SDB.Objects(ObjectName) = CreateMnu
End Function
Function CreateSortOrderMenus(Caption,DrdArray,ObjectName,IniKey)
Dim Mns,Mnu,i
Set Mns = SDB.UI.AddMenuItemSub(UI.Menu_Pop_Tree,1,1)
Mns.Caption = Caption
Mns.IconIndex = 6
Mns.UseScript=Script.ScriptPath
SDB.Objects(ObjectName)=Mns
For i=0 To UBound(DrdArray)
Set Mnu=SDB.UI.AddMenuItem(Mns,0,0)
Mnu.Caption = DrdArray(i)
Mnu.OnClickFunc = "CheckSortOrder" & ObjectName
Mnu.Checked = Eval(INI.IntValue("Last100",IniKey)=i)
Mnu.UseScript=Script.ScriptPath
SDB.Objects(ObjectName & i)=Mnu
Next
End Function
Function CreateGbx(Owner,X,Y,H,W,Caption)
Set CreateGbx = UI.NewGroupBox(Owner)
CreateGbx.Common.SetRect X,Y,H,W
CreateGbx.Caption = Caption
End Function
Function CreateCbx(Owner,X,Y,W,H,Caption,ControlName,Hint,Checked,Enabled,Visible,OnClickName)
Set CreateCbx = UI.NewCheckBox(Owner)
CreateCbx.Common.SetRect X,Y,W,H
CreateCbx.Common.ControlName = ControlName
CreateCbx.Caption = Caption
CreateCbx.Common.Hint = Hint
CreateCbx.Checked = Checked
CreateCbx.Common.Enabled = Enabled
CreateCbx.Common.Visible = Visible
If Not OnClickName="" Then Script.RegisterEvent CreateCbx.Common, "OnClick", OnClickName
End Function
Function CreateLbl(Owner,X,Y,W,H,Caption,ControlName,Visible,FontUnderline)
Set CreateLbl = UI.NewLabel(Owner)
CreateLbl.Common.ControlName = ControlName
CreateLbl.Common.SetRect X,Y,W,H
'CreateLbl.Autosize = True
CreateLbl.Caption = Caption
CreateLbl.Common.Visible = Visible
If FontUnderline then CreateLbl.Common.FontUnderline=True 'FontUnderline
CreateLbl.Common.FontColor=16777208
End Function
Function CreateBtn(Owner,X,Y,W,H,Anchors,Caption,ControlName,OnClickFunc,Hint,ModalResult,DefaultCancel,Visible,Enabled)
Set CreateBtn = SDB.UI.NewButton(Owner)
CreateBtn.Common.SetRect X,Y,W,H
If Not Anchors="" Then CreateBtn.Common.Anchors = Anchors
CreateBtn.Common.ControlName = ControlName
CreateBtn.Caption = Caption
CreateBtn.UseScript = Script.ScriptPath
If Not OnClickFunc="" Then Script.RegisterEvent CreateBtn.Common, "OnClick", OnClickFunc
CreateBtn.Common.Hint = Hint
If ModalResult<>"" Then CreateBtn.ModalResult = ModalResult
If DefaultCancel<>"" Then
If DefaultCancel="Default" Then CreateBtn.Default = True
If DefaultCancel="Cancel" Then CreateBtn.Cancel = True
End If
CreateBtn.Common.Visible = Visible
CreateBtn.Common.Enabled = Enabled
End Function
Function CreateDrd(Owner,X,Y,W,H,ControlName,ShowHint,ItemIndex,OnSelectFunc,Array,Visible,Enabled)
Set CreateDrd = UI.NewDropDown(Owner)
CreateDrd.Common.SetRect X,Y,W,H
CreateDrd.Common.ControlName = ControlName
If Not ShowHint="" Then CreateDrd.Common.Hint = CreateDrd.ItemText(ItemIndex)
FillDropDownFromArray CreateDrd.Common.ChildControl(ControlName), Array
CreateDrd.ItemIndex = ItemIndex
CreateDrd.UseScript = Script.ScriptPath
If Not OnSelectFunc="" Then Script.RegisterEvent CreateDrd, "OnSelect", OnSelectFunc
CreateDrd.Style = 2
CreateDrd.Common.Visible = Visible
CreateDrd.Common.Enabled = Enabled
End Function
Sub FillDropDownFromArray(DropDown, SourceArray)
Dim i
For i = 0 To UBound(SourceArray)
DropDown.AddItem SourceArray(i)
Next
End Sub
Sub CreateFiltersArray()
Dim i : Redim Filters(DB.OpenSql("SELECT COUNT(*) FROM Filters").ValueByIndex(0)+1)
Filters(0) = "- No Filter -"
Filters(1) = "- MM's Active Filter -"
i=2
Dim iter : Set iter = DB.OpenSql("SELECT Name FROM Filters ORDER BY Pos")
Do While Not iter.EOF
Filters(i) = iter.StringByIndex(0)
i=i+1
iter.Next
Loop
Set iter = Nothing
End sub
Function GetFilterID(FilterName)
Select Case FilterName
Case "- No Filter -","- MM's Active Filter -"
GetFilterID = FilterName
Case Else
If DB.OpenSql("SELECT COUNT(*) FROM Filters WHERE Name='"& Replace(FilterName,"'","''") &"'").ValueByIndex(0)>0 Then
GetFilterID = DB.OpenSql("SELECT ID FROM Filters WHERE Name='"& Replace(FilterName,"'","''") &"'").ValueByIndex(0)
Else
GetFilterID = "- No Filter -"
End If
End Select
End Function
Function GetFilterName(FilterID)
Select Case FilterID
Case "- No Filter -","- MM's Active Filter -"
GetFilterName=FilterID
Case Else
If DB.OpenSql("SELECT COUNT(*) FROM Filters WHERE ID="& FilterID).ValueByIndex(0)>0 Then
GetFilterName=DB.OpenSql("SELECT Name FROM Filters WHERE ID="& FilterID).ValueByIndex(0)
Else
GetFilterName = "- No Filter -"
End If
End Select
End Function
Function GetFiltersArrayID(FilterID,fArray)
Dim i
For i=0 To Ubound(fArray)
If fArray(i)=GetFilterName(FilterID) Then
GetFiltersArrayID=i
Exit Function
End If
Next
GetFiltersArrayID=0
End Function
Function GetFilterSQL(PreSQL,FilterID,EndSQL,inikey,UsedWhere)
Select Case FilterID
Case "- No Filter -"
GetFilterSQL = ""
Case "- MM's Active Filter -"
GetFilterSQL = DB.ActiveFilterQuery
Case Else
If DB.OpenSql("SELECT COUNT(*) FROM Filters WHERE ID="& FilterID).ValueByIndex(0)=0 Then
If inikey<>"" Then
SDB.MessageBox "The Filter with ID "& FilterID &", used in "& UsedWhere &", does not any longer exist." & VbNewLine &_
"The Script will continue without any Filter applied.", mtInformation, Array(mbOK)
Ini.StringValue("AdvDupeFindFix",inikey) = "- No Filter -"
End If
GetFilterSQL = ""
Else
GetFilterSQL = DB.GetFilterQuery(FilterID)
End If
End Select
If Not GetFilterSQL = "" Then GetFilterSQL = PreSQL & " " & GetFilterSQL & " " & EndSQL & " "
End Function
__________________________________________________________
Ver 1.5 (2009-07-14)
- Added possibility to add Filters to the Nodes
Ver 1.4 (2009-06-23)
- Added possibility to create indexes on affected fields, to speed up the script
- Added possibility to set sort order of the tracks in the main window
Ver 1.3 (2008-10-07)
- Added a new Node: TrackModified
- Renamed the old node Modified to FileModified
Ver 1.2 (2007-05-13)
- Improved speed considerably
Ver 1.1 (2007-10-16)
- Made the script compatible with MM3
- Added possibilty to edit Last 100 to Last "Any Number". (Press F2 on the node and type the new value.)
___________________________________________________________
Download:
Latest version:
MM3 (Installer)
Last 100... 1.5
Previous version (in case a recent script update by me is malfunctioning):
Last 100... 1.4
Installation Instructions:
- New Install or upgrade:
Avoid "Product installation error"
- Vista Users:
- - To be able to install scripts you must Run MM as an administrator.
- - It means that you must right click the MM icon and select "Run as administrator" even if you are logged in as an administrator.
- All Users:
- - Check in your task manager that you only have one instance of MediaMonkey.exe running.
MM3 (Installer)
1. Download the .mmip file and run it.
2. Restart MediaMonkey if needed
3. Now you will see a new node in the tree: "Last 100 Tracks..."
4. If you wish to change Last 100, simply press F2 on the node and type a new value.

