Incremental Search 1.0 [MM3]

Download and get help for different MediaMonkey for Windows 4 Addons.

Moderators: Peke, Gurus

Kawauso
Posts: 3
Joined: Wed Feb 20, 2008 9:03 pm
Location: Japan

Incremental Search 1.0 [MM3]

Post by Kawauso »

This is small but very useful tool!
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! :D

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
indescribable
Posts: 55
Joined: Fri May 04, 2007 10:44 pm

Post by indescribable »

but doesn't the search already do the same?
† ιη∂εš¢яιвαвℓє™
Kawauso
Posts: 3
Joined: Wed Feb 20, 2008 9:03 pm
Location: Japan

Post by Kawauso »

indescribable wrote:but doesn't the search already do the same?
This search is not the same as existing search function.
When you type a key, songs are displayed automatically without enter key or click 'ok' button.

In addition, dockable panel is not modal window and don't disappear so that you can find changing results by every typing a single key.
indescribable
Posts: 55
Joined: Fri May 04, 2007 10:44 pm

Post by indescribable »

[quote=This search is not the same as existing search function.
When you type a key, songs are displayed automatically without enter key or click 'ok' button.

In addition, dockable panel is not modal window and don't disappear so that you can find changing results by every typing a single key.[/quote]

The changing results thing happens in MM3 as well... unless i'm not getting what you're talking about... but yeah the separate window is cool...
† ιη∂εš¢яιвαвℓє™
nynaevelan
Posts: 5559
Joined: Wed Feb 07, 2007 11:07 pm
Location: New Jersey, USA
Contact:

Re: Incremental Search 1.0 [MM3]

Post by nynaevelan »

Kawauso:

Due to a problem I am having within MM reagarding searches I cannot no longer reliably use the native search functions of Mm until the devs can find a solution to my problem. But I do not know how long that is going to take and if they cannot fix it starting over with a new database is not an option. So I need to find an alternative method for searching, which I do very frequently. I used to use your script when it first came out but since alot of the fields I searched on were missing I gave up using it. But since my problem I have begun using it again, would it be possible to add the Custom and Classification fields to the script?

Nyn
3.2x - Win7 Ultimate (Zen Touch 2 16 GB/Zen 8GB)
Link to Favorite Scripts/Skins

Join Dropbox, the online site to share your files
sa_ill
Posts: 80
Joined: Sun Mar 23, 2008 5:19 pm

Re: Incremental Search 1.0 [MM3]

Post by sa_ill »

This is actually really useful let me tell ya!
Thanks
Image
Post Reply