Shortcut Creator 1.0 [MM2+3]

Download and get help for different MediaMonkey Addons.

Moderators: Peke, Gurus

trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Barton, UK
Contact:

Shortcut Creator 1.0 [MM2+3]

Post by trixmoto » Fri Mar 10, 2006 9:37 am

This script, as requested here, creates shortcuts to the selected tracks in the entered directory.

Code: Select all

'
' MediaMonkey Script
'
' NAME: ShortcutCreator 1.0
'
' AUTHOR: trixmoto (http://trixmoto.net)
' DATE : 10/03/2006 
'
' Thanks for Steegy for the SkinnedInputBox
'
' INSTALL: Copy to Scripts directory and add the following to Scripts.ini 
'          Don't forget to remove comments (') and set the order appropriately
'
' [ShortcutCreator]
' FileName=ShortcutCreator.vbs
' ProcName=ShortcutCreator
' Order=33
' DisplayName=Shortcut Creator
' Description=Shortcut Creator
' Language=VBScript
' ScriptType=0
'
'

Option Explicit 
Dim Progress

Sub ShortcutCreator
  Dim list,res
  Set list = SDB.CurrentSongList
  If list.Count = 0 Then
    res = SDB.MessageBox("There are no selected tracks.",mtInformation,Array(mbOk))
    Set list = Nothing
    Exit Sub
  End If 
  
  Dim path
  path = SDB.IniFile.StringValue("Scripts","LastShortcutPath")
  path = SkinnedInputBox("Please enter full output path:","ShortcutCreator",path,"ShortcutCreator")
  If path = "" Then
    res = SDB.MessageBox("No output directory selected.",mtInformation,Array(mbOk))
    Set list = Nothing
    Exit Sub
  End If
  If Right(path,1) = "\" Then 
    path = Left(path,Len(path)-1)
  End If
 
  Set Progress = SDB.Progress 
  Progress.MaxValue = list.Count
  progtext("Initialising script...")
  
  Dim fso
  Set fso = CreateObject("Scripting.FileSystemObject")
  If not fso.FolderExists(path) Then
    fso.CreateFolder(path)
  End If
  SDB.IniFile.StringValue("Scripts","LastShortcutPath") = path
  
  Dim i,itm,wso,loc,lnk
  Set wso = CreateObject("WScript.Shell")
  For i = 0 To list.Count-1
    Set itm = list.Item(i)
    Progress.Value = i+1
    progtext("Creating shortcut for track "&(i+1)&" of "&list.Count&"...")
    loc = path&"\"&fso.GetBaseName(itm.Path)&".lnk"
    Set lnk = wso.CreateShortcut(loc)
    lnk.TargetPath = itm.Path
    lnk.Save
    Set lnk = Nothing
    Set itm = Nothing
    If Progress.Terminate Then Exit For
  Next

  Set Progress = Nothing  
  Set fso = Nothing
  Set wso = Nothing
  Set list = Nothing
End Sub 

Function progtext(txt)
  progtext = "Shortcut Creator - "&txt
  Progress.Text = progtext
  SDB.ProcessMessages
End Function

Function SkinnedInputBox(Text, Caption, Input, PositionName)
   Dim Form, Label, Edt, btnOk, btnCancel, modalResult 

   ' Create the window to be shown 
   Set Form = SDB.UI.NewForm 
   Form.Common.SetRect 100, 100, 360, 130 
   Form.BorderStyle  = 2   ' Resizable 
   Form.FormPosition = 4   ' Screen Center 
   Form.SavePositionName = PositionName 
   Form.Caption = Caption 
      
   ' Create a button that closes the window 
   Set Label = SDB.UI.NewLabel(Form) 
   Label.Caption = Text 
   Label.Common.Left = 5 
   Label.Common.Top = 10 
     
   Set Edt = SDB.UI.NewEdit(Form) 
   Edt.Common.Left = Label.Common.Left 
   Edt.Common.Top = Label.Common.Top + Label.Common.Height + 5 
   Edt.Common.Width = Form.Common.Width - 20 
   Edt.Common.ControlName = "Edit1" 
   Edt.Common.Anchors = 1+2+4 'Left+Top+Right 
   Edt.Text = Input 
       
   ' Create a button that closes the window 
   Set BtnOk = SDB.UI.NewButton(Form) 
   BtnOk.Caption = "&OK" 
   BtnOk.Common.Top = Edt.Common.Top + Edt.Common.Height + 10 
   BtnOk.Common.Hint = "OK" 
   BtnOk.Common.Anchors = 4   ' Right 
   BtnOk.UseScript = Script.ScriptPath 
   BtnOk.Default = True
   BtnOk.ModalResult = 1 
    
   Set BtnCancel = SDB.UI.NewButton(Form) 
   BtnCancel.Caption = "&Cancel" 
   BtnCancel.Common.Left = Form.Common.Width - BtnCancel.Common.Width - 15 
   BtnOK.Common.Left = BtnCancel.Common.Left - BtnOK.Common.Width - 10 
   BtnCancel.Common.Top = BtnOK.Common.Top 
   BtnCancel.Common.Hint = "Cancel" 
   BtnCancel.Common.Anchors = 4   ' Right 
   BtnCancel.UseScript = Script.ScriptPath 
   BtnCancel.Cancel = True
   BtnCancel.ModalResult = 2 
       
   If Form.showModal = 1 Then
     SkinnedInputBox = Edt.Text
   Else
     SkinnedInputBox = ""
   End If  
End Function
Last edited by trixmoto on Mon Nov 12, 2007 11:04 am, edited 1 time in total.
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Send me BTC: 34VQPVsf9mCeR4nfhFvvBYZqQ7LkqNZ8Mn
Send me LTC: 3P1mzrfbyscdhbxRpXLgKz7tufGAU3SrEG
Send me DOGE: 9xPpYSqgF7P5yQiqvE1VqWb4UjxVCCLFJ6
Check out these great cryptocurrency faucets... BTC / LTC / DOGE

Skyhawker

Post by Skyhawker » Sun Mar 12, 2006 9:39 am

Thanks for your quick response to that...credit to the community and all that :)

I haven't got it to work yet though.
it's in scripts folder as "ShortcutCreator.vbs"
Scripts.ini has been added to ..(what am I meant to change order to? I put 6?)

but I get error: File unavailable, or may not have permission to acces it...I can't think of what to do...I'll come back to it tomorrow when I'm awake..

-Skyhawker

trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Barton, UK
Contact:

Post by trixmoto » Sun Mar 12, 2006 3:24 pm

The order doesn't really matter.

Personally I would suggest downloading the installer for this script from my website. Don't forget you'll need to restart MM before the script is usable!
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Send me BTC: 34VQPVsf9mCeR4nfhFvvBYZqQ7LkqNZ8Mn
Send me LTC: 3P1mzrfbyscdhbxRpXLgKz7tufGAU3SrEG
Send me DOGE: 9xPpYSqgF7P5yQiqvE1VqWb4UjxVCCLFJ6
Check out these great cryptocurrency faucets... BTC / LTC / DOGE

trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Barton, UK
Contact:

Post by trixmoto » Mon Nov 12, 2007 11:03 am

An MM3 installation package is now available from my website for this script. :)
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Send me BTC: 34VQPVsf9mCeR4nfhFvvBYZqQ7LkqNZ8Mn
Send me LTC: 3P1mzrfbyscdhbxRpXLgKz7tufGAU3SrEG
Send me DOGE: 9xPpYSqgF7P5yQiqvE1VqWb4UjxVCCLFJ6
Check out these great cryptocurrency faucets... BTC / LTC / DOGE

Post Reply