View Single Post
Old 22nd November 2004, 02:49   #150
maynardkrebs
Junior Member
 
Join Date: Nov 2004
Posts: 19
ActiveWinamp script for Nero Cover Designer

Hi Y'all.

I've created an ActiveWinamp script that sends the current track selection to Nero 6 Cover Designer. This is a first pass and could use some error trapping etc, but it works as is. I'm sure the general population would appreciate this so I'd like to find a home for it. Suggestions? Feedback?

BTW Shane, ActiveWinamp rocks!!

code:

' ActiveWinamp Script: "sendto_Nero Cover Designer.vbs"
' Desc: Nero Cover Designer SendTo Script

'########################
' CODE
'########################
Const ForReading = 1, ForWriting = 2, ForAppending = 8

Set wsh = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
cdcFile = wsh.ExpandEnvironmentStrings("%TEMP%") & "\watemp.cdc"
Set fcdc = fso.OpenTextFile(cdcFile, ForWriting, True)

sel = GetSendToItems
If ubound(sel) = 0 Then
MsgBox "No tracks selected", vbOKOnly+vbQuestion, "SendTo Nero Cover Designer"
Quit
End If

' Get total selection time
plTime = 0
for each track in sel
plTime= plTime + track.Length
next

' Write collection info
fcdc.WriteLine("[Parameters]")
fcdc.WriteLine("Language=English")
fcdc.WriteLine("[CDINFO]")
fcdc.WriteLine("Type=Audio-CD")
fcdc.WriteLine("Title=Winamp")
fcdc.WriteLine("Artist=Winamp")
fcdc.WriteLine("Tracks=" & ubound(sel))
fcdc.WriteLine("Playtime=" & ConvertSeconds(plTime))

' Write track info
i=1
for each track in sel
fcdc.WriteLine("[Track" & i & "]")
fcdc.WriteLine("Type=Audio")
fcdc.WriteLine("Artist=" & track.Artist)
fcdc.WriteLine("Title=" & track.Title)
fcdc.WriteLine("Playtime=" & ConvertSeconds(track.Length))
i=i+1
next

fcdc.Close

' Launch Nero Cover Designer
ncdPath = wsh.RegRead("HKLM\SOFTWARE\Classes\Nero Cover Designer.Document\shell\open\command\\")
ncdPath = Left(ncdPath, InStr(ncdPath, " /dde"))
wsh.Exec(ncdPath & " " & cdcFile)

Quit


'########################
' FUNCTIONS
'########################

Function ConvertSeconds(lSeconds)
Dim lTmpMinutes
Dim lTmpSeconds
Dim lTmpHours

If lSeconds > 59 Then
'Get's *just* the amount of seconds that will be returned
lTmpSeconds = lSeconds Mod 60
'Do we have more than an hour's worth of seconds?
If lSeconds > 3599 Then
'How many hours are we talking about
lTmpHours = Fix(lSeconds / 3600)

'Take the original seconds and figure out
'how many minutes we have. Then remove from that
'anything that says "60" for the minutes. So we
'don't have "2:60:05"
lTmpMinutes = lSeconds / 60 - (60 * lTmpHours)

'Finally return the value all nicely formatted up
ConvertSeconds = lTmpHours & ":" & _
FormatTime(lTmpMinutes) & ":" & _
FormatTime(lTmpSeconds)
Else
'Ok. We've got something less than an hour.
'How many minutes do we have?
lTmpMinutes = Fix(lSeconds / 60)

'Seconds were already figured above (lSeconds Mod
'60) so we just return the value and we be done.
ConvertSeconds = lTmpMinutes & ":" & _
FormatTime(lTmpSeconds)
End If
Else
'This is for the lazy that sends us less than even a
'*minutes* worth of seconds. Just dress it up and send
'it back.
ConvertSeconds = "0:" & FormatTime(lSeconds)
End If
End Function


Function FormatTime(tval)
If tval < 10 Then
FormatTime = "0" & tval
Else
FormatTime = CStr(tval)
End If
End Function


Last edited by maynardkrebs; 22nd November 2004 at 03:05.
maynardkrebs is offline   Reply With Quote