Page 1 of 2

User defined action

Posted: Thu Aug 14, 2003 11:31 am
by Guest
As suggested I immediately uprgaded to MediaMonkey Gold and now I'm asking for help.

I need a script which launches the external application (in my case a sound file editor) with the path to currently selected MP3 file.

I'm currently browsing though MSDN searching for any clues how to achive that goal - probably through WScript.Shell object's run method - but I'm not too familiar with VBScript.

My MediaMonkey (build 1.543) doesn't display any scripts menu - is that okay? Songs-DB displays scripts menu therefore I can use them.

Any help appreciated.

Posted: Thu Aug 14, 2003 1:25 pm
by jiri
Ok, an easy version of the script could look like:

Sub OpenInWinamp
Dim WShell, Command, list, itm

Set list = SDB.SelectedSongList
If list.count=0 Then
Exit Sub
End If

Set itm = list.Item(0)

Set WShell = CreateObject("WScript.Shell")
Command = Chr(34)&"C:\Program Files\Winamp\winamp.exe"&Chr(34) &" "&Chr(34)&itm.Path&Chr(34)
WShell.Run Command, 1, 0
End Sub


This script simply opens selected track in WinAmp (providing paths are correct).

An entry in scripts.ini could be
[OpenInWinamp]
FileName=MyScripts.vbs
ProcName=OpenInWinamp
Order=1
DisplayName=Open file in WinAmp
Description=Open file in WinAmp
Language=VBScript
ScriptType=0

The important thing is the last line: 'ScriptType=0', because then the script will appear in Tools|Scripts (which is by default invisible, only visible when such script exists). Otherwise is appears in Export scripts.

Hope it helps,
Jiri

Posted: Fri Aug 15, 2003 7:09 am
by Maciek
Thank you very much. The script works perfectly. Now I have to merge my keywords database with MediaMonkey and I will have the perfect tool for my job. $20 well spent.

Thanks again,
Maciek

Start Of External Programs

Posted: Mon Aug 18, 2003 3:30 am
by Peke
I'm Developing An App that will be a third party Program which will make that script and manage existen, Stay tunned :))

Posted: Fri Jul 02, 2004 1:56 pm
by Peke
I do not know what you R talking about?

Talking to yourself?

Posted: Thu Jul 08, 2004 1:08 am
by rusty
Peke are you talking to yourself again? You've got to quit working so hard.

:P :D

Posted: Thu Jul 08, 2004 2:37 pm
by Peke
Sorry Those two msgs are mentioned for for 2 different Topics ;) I do not know how this happend, but sure. Can I take vocation and leave unfinished bisnis ;) :P :D

Posted: Wed Sep 28, 2005 7:32 pm
by michael
Here is a modification in Jiri's script to allow the user to send to winamp from the "send to" menu in either the Track List or the Playing Now panes.

I am using code snippets from Peke script to make it work, but the new script is simple and small, and uses winamp instead of a custom exe file (which was the case in Peke's original script)

Code: Select all

' A simple script that shows how to open a selected track in another application.
' In this case it is WinAmp (expected to be in C:\Program Files\Winamp\winamp.exe).

Const WinAmpPath = "C:\Program Files\Winamp\winamp.exe"

Sub OnStartup

  Dim POPSMonitor
  Set POPSMonitor = SDB.UI.AddMenuItem(SDB.UI.Menu_Pop_TrackList_SendTo,0,0)
  POPSMonitor.Caption = "Send to Winamp"
  POPSMonitor.OnClickFunc = "OpenInWinampNew"
  POPSMonitor.UseScript = Script.ScriptPath
  POPSMonitor.IconIndex = 40

  Set POPSMonitor = SDB.UI.AddMenuItem(SDB.UI.Menu_Pop_NP_SendTo,0,0)
  POPSMonitor.Caption = "Send to Winamp"
  POPSMonitor.OnClickFunc = "OpenInWinampNew"
  POPSMonitor.UseScript = Script.ScriptPath
  POPSMonitor.IconIndex = 40

  Dim POPSPreview
  Set POPSPreview = SDB.UI.AddMenuItem(SDB.UI.Menu_Pop_TrackList_SendTo,0,0)
  POPSPreview.Caption = "Send Preview to Winamp"
  POPSPreview.OnClickFunc = "OpenInWinampPreview"
  POPSPreview.UseScript = Script.ScriptPath
  POPSPreview.IconIndex = 18

  Set POPSPreview = SDB.UI.AddMenuItem(SDB.UI.Menu_Pop_NP_SendTo,0,0)
  POPSPreview.Caption = "Send Preview to Winamp"
  POPSPreview.OnClickFunc = "OpenInWinampPreview"
  POPSPreview.UseScript = Script.ScriptPath
  POPSPreview.IconIndex = 18  
End Sub

Sub OpenInWinampPreview  (arg)
  Dim WShell, Command,  Song

  If SDB.SelectedSongList.item(0).Preview = 0 Then
    Result = SDB.MessageBox( "Selected Track do not have Preview.", mtError, Array(mbOk))
    Exit sub
  END IF

  Set Song = SDB.SelectedSongList.item(0)
  Set WShell = CreateObject("WScript.Shell")

  Command = Chr(34) & WinAmpPath & Chr(34) & " " & Chr(34) & Song.PreviewPath & Chr(34) 

  WShell.Run Command, 1, 0
End Sub


Sub OpenInWinampNew (arg)
  ' Define variables
  Dim WShell, Command, list, itm 

  ' Get list of selected tracks from MediaMonkey
  Set list = SDB.SelectedSongList 

  ' Make sure at least one track is selected
  If list.count=0 Then 
    Exit Sub 
  End If 

  ' Get the first selected track
  Set itm = list.Item(0) 
 
  ' Prepare WScript.Shell object, which can be used for execution of applications
  Set WShell = CreateObject("WScript.Shell") 

  ' Prepare command to execute
  Command = Chr(34) & WinAmpPath & Chr(34) & " " & Chr(34) & itm.Path & Chr(34) 

  ' And execute the command
  WShell.Run Command, 1, 0 
End Sub 
To install copy the code into a text file and place it in the Scripts/Auto under your media monkey folder.

Posted: Tue Dec 27, 2005 9:23 am
by guest
Hi,

what must I do then if I want to hand over not the whole name of the file to an external program, but only the path of the file?

I have tried a lot. But nothing goes.

Posted: Tue Mar 14, 2006 3:59 am
by QuadU
And what must I do to open not only the first title of some selected tracks but all?

Posted: Tue Mar 14, 2006 11:36 am
by Steegy

Code: Select all

And what must I do to open not only the first title of some selected tracks but all?
Such scripts already exist.
The most reliable script for me is ExportM3UAndPlayInWinamp ( http://www.mediamonkey.com/forum/viewtopic.php?t=6566 ). It doesn't crash Winamp when large amounts of tracks are copied, like other scripts cause. (that's why I made this script...)

Cheers
Steegy

Posted: Tue Mar 14, 2006 11:41 am
by Steegy
what must I do then if I want to hand over not the whole name of the file to an external program, but only the path of the file?
Use the File object of the FileSystemObject to get the folder path. If you don't want to use this (or want a faster way), you can use InstrRev to search that path separator '\' and then take the part of the string before that position (using the Left function).

The code is very simple, but I don't completely know these functions by heart, so maybe you can do some useful reserach for your own (http://msdn.microsoft.com/scripting --> scripting reference: VbScript)

Cheers
Steegy

Posted: Wed Mar 29, 2006 3:25 am
by vonster
I'm trying to modify this script to run another app rather than Winamp.

specifically: a tag editor called Mp3edit that has some more advanced tagging and renaming features.

i want to select a group of files, then "Send to Mp3edit" to mass edit and rename tags .... i dont need a "Send Preview to Mp3edit" obviously, so im trying to delete that from the script

I have the script modified here - mainly just using a simple replace 'winamp' with 'mp3edit' and removing the subs for the preview function

seems to load fine - puts the menu item in "Send To"... but gives me the following error boxes when i try and send files:

"Error # -
File://[path]/OpenWA.vbs, line: 75, Column: 2" {this is last line in script]

OK .. then ...

"Error happened during script, the system can not find the file specified"


Obviously i dont need a "Send Preview to Mp3edit", so id like to remove that too ... but for now it would be enough just to get this to send to my application so i can work

Anybody? Its probably simple but i dont know VBscript and cant find the error ... script below ... does this require an INI modification too? because im not sure how that fits in here either ...

thanks, much appreciated .........


---

' A simple script that shows how to open a selected track in another application.
' In this case it is Mp3edit (expected to be in C:\Program Files\Mp3edit\Mp3edit.exe).

Const Mp3editPath = "C:\Program Files\Mp3edit\Mp3edit.exe"

Sub OnStartup

Dim POPSMonitor
Set POPSMonitor = SDB.UI.AddMenuItem(SDB.UI.Menu_Pop_TrackList_SendTo,0,0)
POPSMonitor.Caption = "Send to Mp3edit"
POPSMonitor.OnClickFunc = "OpenInMp3editNew"
POPSMonitor.UseScript = Script.ScriptPath
POPSMonitor.IconIndex = 40

Set POPSMonitor = SDB.UI.AddMenuItem(SDB.UI.Menu_Pop_NP_SendTo,0,0)
POPSMonitor.Caption = "Send to Mp3edit"
POPSMonitor.OnClickFunc = "OpenInMp3editNew"
POPSMonitor.UseScript = Script.ScriptPath
POPSMonitor.IconIndex = 40
End Sub


Sub OpenInMp3editNew (arg)
' Define variables
Dim WShell, Command, list, itm

' Get list of selected tracks from MediaMonkey
Set list = SDB.SelectedSongList

' Make sure at least one track is selected
If list.count=0 Then
Exit Sub
End If

' Get the first selected track
Set itm = list.Item(0)

' Prepare WScript.Shell object, which can be used for execution of applications
Set WShell = CreateObject("WScript.Shell")

' Prepare command to execute
Command = Chr(34) & Mp3editPath & Chr(34) & " " & Chr(34) & itm.Path & Chr(34)

' And execute the command
WShell.Run Command, 1, 0
End Sub

Posted: Wed Mar 29, 2006 3:47 am
by trixmoto
The script works perfectly for me. Presumably either the location is incorrect, or you do not have the most recent WScript version (5.6) - maybe try downloading that from microsoft.com

Posted: Wed Mar 29, 2006 4:42 am
by vonster
trixmoto wrote:The script works perfectly for me. Presumably either the location is incorrect, or you do not have the most recent WScript version (5.6) - maybe try downloading that from microsoft.com
are you saying you tried my script modification out the way i just listed it, and its working for you?


.