When you install it, you can see 'Incremental Search' node and small dockable panel.
Everytime you type any key in the textbox, songs including the keys in 'Artist', 'Album' or 'Title' columns display in auto-focused 'Incremental Search' node.
You can change default checkbox settings by altering following three variables to 'False'.
Const ARTIST_DEFAULT_CHECK = True
Const ALBUM_DEFAULT_CHECK = True
Const TITLE_DEFAULT_CHECK = True
This is my first coding of MediaMonkey's script.
Please let me know any impression, request and bug!
Code: Select all
'
' MediaMonkey Script
'
' NAME: Incremental Search 1.0 [MM3]
' AUTHOR: Kawauso
' DATE: Feb, 20, 2008
'
' INSTALL: Copy this code and save to 'Scripts/Auto' directory.
'
' NOTE: All checkboxes are checked by default.
' You can change it by setting following three const variables.
'
Const ARTIST_DEFAULT_CHECK = True
Const ALBUM_DEFAULT_CHECK = True
Const TITLE_DEFAULT_CHECK = True
Dim Tree, Node, Mnu, Pnl, Edt, ChkArtist, ChkAlbum, ChkSongTitle
Sub OnStartup
Set UI = SDB.UI
Set Tree = SDB.MainTree
Set Node = Tree.CreateNode
Node.Caption = "Incremental Search"
Node.IconIndex = 24
Node.SortGroup = 1
Tree.AddNode Tree.Node_Library, Node, 0
Script.RegisterEvent Node, "OnNodeFocused", "QuerySearch"
Set Pnl = UI.NewDockablePersistentPanel("IncrementalSearch")
Pnl.DockedTo = 1
Pnl.Common.Width = 200
Pnl.Common.Height = 45
Pnl.Caption = "Incremental Search"
Script.RegisterEvent Pnl, "OnClose", "PnlClose"
'--- Add menu item that shows panel after it is closed ---
Set Sep = SDB.UI.AddMenuItemSep(SDB.UI.Menu_View,0,0)
Set Mnu = SDB.UI.AddMenuItem(SDB.UI.Menu_View,0,0)
Mnu.Caption = "Incremental Searchl"
Mnu.Checked = Pnl.Common.Visible
Script.RegisterEvent Mnu, "OnClick", "ShowPanel"
'--- Add edit and checkbox to panel ---
Set Edt = UI.NewEdit(Pnl)
Edt.Common.SetRect 2, 2, Pnl.Common.ClientWidth-4, 10
Edt.Common.Anchors = 7
Script.RegisterEvent Edt, "OnChange", "OnEditBoxChange"
Set ChkArtist = UI.NewCheckBox(Pnl)
Script.RegisterEvent ChkArtist.Common, "OnClick", "OnEditBoxChange"
With ChkArtist
.Caption = "Artist"
.Checked = ARTIST_DEFAULT_CHECK
.Common.SetRect 6, 24, Pnl.Common.ClientWidth-4, 20
.Common.Anchors = 7
End With
Set ChkAlbum = UI.NewCheckBox(Pnl)
Script.RegisterEvent ChkAlbum.Common, "OnClick", "OnEditBoxChange"
With ChkAlbum
.Caption = "Album"
.Checked = ALBUM_DEFAULT_CHECK
.Common.SetRect 60, 24, Pnl.Common.ClientWidth-4, 20
.Common.Anchors = 7
End With
Set ChkSongTitle = UI.NewCheckBox(Pnl)
Script.RegisterEvent ChkSongTitle.Common, "OnClick", "OnEditBoxChange"
With ChkSongTitle
.Caption = "Title"
.Checked = TITLE_DEFAULT_CHECK
.Common.SetRect 118, 24, Pnl.Common.ClientWidth-4, 20
.Common.Anchors = 7
End With
End Sub
Sub QuerySearch( Item)
Pnl.Common.Visible = True
Mnu.Checked = True
Dim Tw : Set Tw = SDB.MainTracksWindow
Dim StrSQL : StrSQL = ""
Dim StrKey : StrKey = Replace(Edt.Text, "'", "''")
Dim StrOrder : StrOrder = "ORDER BY Artist"
If Edt.Text <> "" Then
If ChkArtist.Checked Then StrSQL = StrSQL & "Artist LIKE '%" & StrKey & "%' OR "
If ChkAlbum.Checked Then StrSQL = StrSQL & "Album LIKE '%" & StrKey & "%' OR "
If ChkSongTitle.Checked Then StrSQL = StrSQL & "SongTitle LIKE '%" & StrKey & "%' OR "
If Len(StrSQL) <> 0 Then
StrSQL = "WHERE " & Left(StrSQL, Len(StrSQL)-3)
Else
StrSQL = "WHERE ID = -1 "
End If
Tw.AddTracksFromQuery(StrSQL & StrOrder)
Tw.FinishAdding
Else
Tw.AddTracksFromQuery(StrOrder)
Tw.FinishAdding
End If
End Sub
Sub ShowPanel( Item)
Pnl.Common.Visible = not Pnl.Common.Visible
Mnu.Checked = Pnl.Common.Visible
End Sub
Sub PnlClose( Item)
Mnu.Checked = false
End Sub
Sub OnEditBoxChange( Item)
If Tree.CurrentNode.Caption = Node.Caption Then
SDB.MainTracksWindow.Refresh
Else
Tree.CurrentNode = Node
End If
End Sub
