by revbob » Wed Apr 12, 2006 10:49 pm
Now, thanks to Steegy, it turns off the player when you close the window. This is so cool!
Code: Select all
'==========================================================================
'
' MediaMonkey Script
'
' NAME: PandoraNode v1.1
' DESCRIPTION:
' Adds a node to the Web menu that opens Pandora (or substitute your
' favorite web page) either in your default web browser or in a popup
' child window of MM.
'
' Heavily indebted to StreamsTreeNode by Steegy
' http://www.mediamonkey.com/forum/viewtopic.php?t=8336
' and openlink.vbs by tvjunky
' http://www.mediamonkey.com/forum/viewtopic.php?t=5407
' and jiri's application note on scripting features in 2.5.2
' http://www.mediamonkey.com/forum/viewtopic.php?t=7660
'
' AUTHOR: Bob Crispen
' DATE : 12.04.2006
'
' INSTALL:
' - Copy script to MediaMonkey's "Scripts\Auto" folder
'
'==========================================================================
'>> ForumURL: http://www.mediamonkey.com/forum/viewtopic.php?p=37961
'>> ScriptName: PandoraNode
'>> VersionNumber: 1.1
'>> Author: Bob Crispen
'>>>>EndOfProperties
'##############################################################################################
Dim Tree
' OnStartup event handler
Sub OnStartup
' Point to the main tree
Set Tree = SDB.MainTree
' Create a node
Dim PandoraNode
Set PandoraNode = Tree.CreateNode
' Fill in the node label, icon, URL to open, this script, and the
' function to call when you click on the node.
PandoraNode.Caption = "Pandora"
PandoraNode.IconIndex = 37
PandoraNode.CustomData = "http://www.pandora.com/"
PandoraNode.UseScript = Script.ScriptPath
' Pick one
Script.RegisterEvent PandoraNode, "OnNodeFocused", "OpenInPopup"
' Script.RegisterEvent PandoraNode, "OnNodeFocused", "OpenInDefaultBrowser"
' Under the Web main tree node seems like a logical place for Pandora
Tree.AddNode Tree.Node_Web, PandoraNode, 2
End Sub
' OnClose event handler
Sub FormClose(Node)
SDB.Objects("Pandora Window") = Nothing
SDB.Objects("Pandora Browser").Navigate "about:blank"
SDB.Objects("Pandora Browser") = Nothing
End Sub
' Open up the URL in your default web browser
Sub OpenInDefaultBrowser(Node)
Dim WPandoraShell, Command
Set WPandoraShell = CreateObject("WScript.Shell")
Command = Node.CustomData
Result = WPandoraShell.Run(Command, 0, 0)
End Sub
' Open the URL in a popup window containing a browser control.
Sub OpenInPopup(Node)
Dim Form, BrowserControl, Command
Command = Node.CustomData
Set Form = SDB.UI.NewForm
Form.Common.SetRect 100, 100, 900, 700
Form.Caption = Command
Set BrowserControl = SDB.UI.NewActiveX(Form, "Shell.Explorer")
BrowserControl.Common.Align = 5 ' Fill all client rectangle
BrowserControl.Interf.Navigate Command ' Go to the specified URL
Form.Common.Visible = True
SDB.Objects("Pandora Window") = Form ' Make the window hang about
SDB.Objects("Pandora Browser") = BrowserControl.Interf
Script.RegisterEvent Form, "OnClose", "FormClose"
End Sub
Probably lots of solecisms (like, why is Tree global? do you have to Dim stuff and then Set it?) because I know exactly zero Visual Basic. But it works and doesn't do stuff that's half as evil as a lot of programs I run all the time.
Thanks, Steegy.
Now, thanks to Steegy, it turns off the player when you close the window. This is so cool!
[code]
'==========================================================================
'
' MediaMonkey Script
'
' NAME: PandoraNode v1.1
' DESCRIPTION:
' Adds a node to the Web menu that opens Pandora (or substitute your
' favorite web page) either in your default web browser or in a popup
' child window of MM.
'
' Heavily indebted to StreamsTreeNode by Steegy
' http://www.mediamonkey.com/forum/viewtopic.php?t=8336
' and openlink.vbs by tvjunky
' http://www.mediamonkey.com/forum/viewtopic.php?t=5407
' and jiri's application note on scripting features in 2.5.2
' http://www.mediamonkey.com/forum/viewtopic.php?t=7660
'
' AUTHOR: Bob Crispen
' DATE : 12.04.2006
'
' INSTALL:
' - Copy script to MediaMonkey's "Scripts\Auto" folder
'
'==========================================================================
'>> ForumURL: http://www.mediamonkey.com/forum/viewtopic.php?p=37961
'>> ScriptName: PandoraNode
'>> VersionNumber: 1.1
'>> Author: Bob Crispen
'>>>>EndOfProperties
'##############################################################################################
Dim Tree
' OnStartup event handler
Sub OnStartup
' Point to the main tree
Set Tree = SDB.MainTree
' Create a node
Dim PandoraNode
Set PandoraNode = Tree.CreateNode
' Fill in the node label, icon, URL to open, this script, and the
' function to call when you click on the node.
PandoraNode.Caption = "Pandora"
PandoraNode.IconIndex = 37
PandoraNode.CustomData = "http://www.pandora.com/"
PandoraNode.UseScript = Script.ScriptPath
' Pick one
Script.RegisterEvent PandoraNode, "OnNodeFocused", "OpenInPopup"
' Script.RegisterEvent PandoraNode, "OnNodeFocused", "OpenInDefaultBrowser"
' Under the Web main tree node seems like a logical place for Pandora
Tree.AddNode Tree.Node_Web, PandoraNode, 2
End Sub
' OnClose event handler
Sub FormClose(Node)
SDB.Objects("Pandora Window") = Nothing
SDB.Objects("Pandora Browser").Navigate "about:blank"
SDB.Objects("Pandora Browser") = Nothing
End Sub
' Open up the URL in your default web browser
Sub OpenInDefaultBrowser(Node)
Dim WPandoraShell, Command
Set WPandoraShell = CreateObject("WScript.Shell")
Command = Node.CustomData
Result = WPandoraShell.Run(Command, 0, 0)
End Sub
' Open the URL in a popup window containing a browser control.
Sub OpenInPopup(Node)
Dim Form, BrowserControl, Command
Command = Node.CustomData
Set Form = SDB.UI.NewForm
Form.Common.SetRect 100, 100, 900, 700
Form.Caption = Command
Set BrowserControl = SDB.UI.NewActiveX(Form, "Shell.Explorer")
BrowserControl.Common.Align = 5 ' Fill all client rectangle
BrowserControl.Interf.Navigate Command ' Go to the specified URL
Form.Common.Visible = True
SDB.Objects("Pandora Window") = Form ' Make the window hang about
SDB.Objects("Pandora Browser") = BrowserControl.Interf
Script.RegisterEvent Form, "OnClose", "FormClose"
End Sub
[/code]
Probably lots of solecisms (like, why is Tree global? do you have to Dim stuff and then Set it?) because I know exactly zero Visual Basic. But it works and doesn't do stuff that's half as evil as a lot of programs I run all the time.
Thanks, Steegy.