ExtractFields v0.1.4 [MM2+3]

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

Moderators: Peke, Gurus

clapiotte
Posts: 1
Joined: Tue Jun 05, 2007 5:44 pm

folder name

Post by clapiotte »

Hi guys,
thanks for this nice script. I hade a hard time understanding that "Author" is actually "Composer" and that "MusicComposer" is actually... no idea.

Ok I'm writing because I'd like to put the song folder name into the tag "Author" (don't ask why, this is an ipod stuff). So I do:

Author <-- <Folder>

Unfortunatelly, the result is "%P" in the Composer Tag.

Any idea, anyone?
Thanks, Laurent (from Paris)
Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm

Post by Steegy »

Yes, the script is designed for that not to work :)

To write the complete file path (not only the folder name), add

Code: Select all

  .Add "%P", "Path" 
at the bottom of the script (you'll see where it has to be). But probably that isn't what you want.

However, the script could be extended to allow VBScript functions in the "mask". Anyone is welcome to post an addition for that :).
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
sonicendeavor
Posts: 28
Joined: Thu Dec 29, 2005 10:28 pm

Post by sonicendeavor »

This is good stuff! I'm just getting into scripting and it sure beats the way I was doing it before with MS Access update queries. Oh well, live and learn.
I use this script to copy tag info into the comments field to be used in iTunes, but there's an issue with the Language field. MM sets the Language field in the ID3 tag to XXX, which iTunes ignores. Setting it to "eng" allows iTunes to see the Comments field. Is there any way for a script to set the Language field in the tag? I tried Song.Language just for the heck of it, but it didn't work.
Thanks for your help.
Bill
Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm

Post by Steegy »

Afaik the "Language" tag is not (yet) 'supported' by MM. There's a temporary list of MM3 SongData fields (MM3 is still an Alpha, so more fields might be added later). This list doesn't contain 'Language', so it's not (yet) possible to change this tag directly through MM scripting.

However, maybe it's possible to write to the 'Language' tag by:
- setting the Language field of a song directly in the database (use an SQL UPDATE query; see AddSongInfo > TextData > 501:AIF_LANGUAGE)
- then write the song's fields to the tags (e.g. using SDBSongData::WriteTags).
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
sonicendeavor
Posts: 28
Joined: Thu Dec 29, 2005 10:28 pm

Post by sonicendeavor »

Thanks.
Unfortunately the "Language" that's incorrect is in the first 3 bytes of the comment frame as opposed to the language tag. It's a known problem in MM, as XXX is not a valid language code. It should either default to the abbreviation of the language field in the tag (ie "eng"), or to spaces.
A mass update using The Godfather tagger takes care of this, as it sets the language in the comments frames based on the song language.
Now if I can just get the MM tag updating process to stop messing with the volume setting in iTunes, I'd be all set.
Guest

Post by Guest »

can set it as default like

Code: Select all

Const def_TagMask = "%X %S"
[/quote]

That was the part I needed to know, that %X = "skip"
Eyal
Posts: 3116
Joined: Sun Jun 26, 2005 9:27 am
Location: Québec

Post by Eyal »

Is there a way to disable the localisation of the script?
I use MM in French but want ExtractFields to be in English, because otherwise it's only a mix-up of English+French, and I can't find the celsius special character on my keyboard to enter the <track#> field:

Image

Thank you
Skins for MediaMonkey: Cafe, Carbon, Helium, Spotify, Zekton. [ Wiki Zone ].
Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm

Post by Steegy »

I'm affraid not. This script uses MediaMonkey's built-in capability to recognize the masks. Most users probably prefer this way, because it works 100% like it is in MediaMonkey itself. That meand that users can use their own language, but this can also be a problem.
But you do have the same issue with "Auto-Tag from Filename" and "Auto-Organize", don't you? Isn't that a reason to use MM in English?

That said, what you want can be added without using MediaMonkey's ability (sure the code will grow) and I already thought of/began with that, but not from a language prespective. I'll add a wish to the scripting functionality wishlist, to be able to define the localization when using the relevant scripting functions.
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
Mizery_Made
Posts: 2283
Joined: Tue Aug 29, 2006 1:09 pm
Location: Kansas City, Missouri, United States

Post by Mizery_Made »

Maybe another fix would be to mimic Auto-Organize/Auto-Tag From Filename in the sense of making the "field list" items clickable. So, you could click the French equivalent of '<Track#>' and it would input it into the mask area for you?

Then again, this may not be possible with Scripts and/or may actually call for more new code then your current idea for a fix. Just shooting ideas though.
Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm

Post by Steegy »

Yes, that was how it was supposed to work, but the MediaMonkey edit control doesn't allow that functionality, and there's no toolbar which we can use in scripts (like in Auto-Organize, with the button effect). The field list would be clickable, but it wouldn't show the button effect.
However, I have done this in another script, using an external control. Maybe I could use this here too, but then the script should come with an installer. You don't mind that? Or would you actually prefer an installer?
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
tj_junk
Posts: 71
Joined: Thu Apr 13, 2006 10:10 am

Clickable tags are "somewhat" possible

Post by tj_junk »

Miz_Made,

I modified Steegy's wonderful script for my own use so that you can click the tags just like Auto-Organize to build your input mask. The only problem is that it only works for the first input mask textbox. Due to the limited events supported by MM and my limited knowledge of VBScript, I could not get the "Click and Insert" feature to work for any input masik textbox, other than the first one.

I was hoping that I could set a variable whenever I "entered" one of the textboxes (something like an "OnFocus" event) so that I could "Click and Insert" to the last entered mask textbox. Well, I couldn't get that to work. But, my tweak does work great for the first textbox, and that's perfect for most of the times that I use this script.

A couple of notes:
  • 1) I created a constant called "def_TagSeparator" which you can customize to insert a default separator string between tags, whenever you click on a tag to insert it. (It ignores the tag separator when you're inserting the first tag to the mask.)
    2) All current scripts will be "broken" in MM3.0. So, beware -- this script works great for now, but it will have to be totally rewritten for the next version of MM.
Anyways, enjoy for now!

Here's my version of the script:

Code: Select all

'==================================================================================== 
' 
' MEDIAMONKEY SCRIPT: ExtractFields v0.1.3 (last updated 2007-02-01)    by   Steegy aka RC (Ruben Castelein) 
' 
'  Change your tags using the contents of the current tags. 
'  You can use different "entry lines". Each entry line gets/puts it's information 
'   from/in the specified information field (chosen from the dropdown list). The mask that you specify will 
'   make sure that the chosen information field gets parsed and the other fields are filled with the info, 
'   or that the chosen information field will be filled like specified in the mask. 
'  This script is generally applicable and can be used to replace scripts like: 
'   - SwapArtistTitle 
'   - SwitchOrCopyFields 
'   - Split Artist Title 
'   and maybe other. 
' 
'  Responsability for using this script (in all cases, in any way) is all on your own shoulders. 
' 
'==================================================================================== 
Option Explicit 

'***************************************************** 
'****                USER DEFAULTS                **** 
'***************************************************** 

'******************************************************************************* 
'****   TJ START   *************************************************************

Const def_TagSeparator = " "    ' Used to separate tag masks that are added via the tag mask buttons

'****   TJ END   ***************************************************************
'******************************************************************************* 
Const def_EntryLinesCnt = 2 
Const def_TagField = "Title" 
Const def_TagMask = "%A - %S" 
'******************************************************************************* 
'TODD:  INCREASE THIS FOR FLEXIBIILITY
'******************************************************************************* 

'***************************************************** 
'****              SCRIPT PROPERTIES              **** 
'***************************************************** 

Const RequiredMMVersion = 253 
Const ScriptName = "ExtractFields" 
Const ScriptCaption = "Extract Fields..." 
Const ScriptHint = "Change tags based on existing tags" 
Const ScriptShortCut = "Ctrl+Alt+X" 


'***************************************************** 
'****             GLOBAL DECLARATIONS             **** 
'***************************************************** 

Dim Form, lblMasks, edtMasks, SpinEdit, lblPemTag, btnPem, lblPemValue, lblSpin, btnSpin, btnClose, btnExtractFields 
'******************************************************************************* 
'****   TJ START   *************************************************************
'******************************************************************************* 
Dim btnMaskTags
Dim current_editbox
'******************************************************************************* 
'****   TJ END   ***************************************************************
'******************************************************************************* 
Dim NumberOfEntryLines 
Dim DataFieldsArray() 
Dim MaskTextArray() 
Dim EnableStateArray() 
Dim DirectionArray() 
Dim ParseEntryMethod 

Const pemSerial = 1 
Const pemParallel = 2 


'***************************************************** 
'****                 ENTRY POINT                 **** 
'***************************************************** 

Sub OnStartup 

    Dim CurrentVersion : CurrentVersion = SDB.VersionHi & SDB.VersionLo & SDB.VersionRelease 

    If CurrentVersion < RequiredMMVersion Then 
        Dim RequiredMMVersionString : RequiredMMVersionString = Mid(RequiredMMVersion, 1, 1) & "." & Mid(RequiredMMVersion, 2, 1) & "." & Mid(RequiredMMVersion, 3, 1) 
        Dim Text 
        Text = "'" & ScriptName & "' needs MediaMonkey " & RequiredMMVersionString & " or above." + vbNewLine 
        Text = Text & "Please Download the latest Version on http://www.MediaMonkey.com" & vbNewLine & vbNewLine 
        SDB.MessageBox Text, mtError, Array(mbOK) 
    Else 
        Dim MenuItem : Set MenuItem = SDB.UI.AddMenuItem(SDB.UI.Menu_Scripts, 0, -1) 
        MenuItem.Caption = ScriptCaption 
        MenuItem.Hint = ScriptHint 
        MenuItem.IconIndex = 25 
        MenuItem.ShortCut = ScriptShortCut 
        Script.RegisterEvent MenuItem, "OnClick", ScriptName 
        
        Dim TBItem : Set TBItem = SDB.UI.AddMenuItem(SDB.UI.Menu_TbStandard, 0, -1) 
        TBItem.Caption = ScriptCaption 
        TBItem.Hint = ScriptHint 
        TBItem.IconIndex = 25 
        TBItem.ShortCut = ScriptShortCut 
        Script.RegisterEvent TBItem, "OnClick", ScriptName 
    End If 

End Sub 


'******************************************************************************* 
'****   
'******************************************************************************* 
Sub ExtractFields(MenuItem) 

    Set Form = CreateForm("Change tags based on existing tags", 100, 100, 495, 140, bsDialog, poScreenCenter, True, "ExtractFields_Form") 
    
    
    Call CreateLabel(Form, "Enabled", 7, 15, 50, 20) 
    Call CreateLabel(Form, "Field name", 85, 15, 60, 20) 
    Call CreateLabel(Form, "Mask to recognise or tag", 280, 15, 120, 20) 
    
    
    Set lblSpin = CreateLabel(Form, "Entry lines # :", 20, 0, 70, 20) 
    
    Set SpinEdit = CreateSpinEdit(Form, 95, 0, 50, 20, "SpinEdit") 
    SpinEdit.MinValue = 1 
    SpinEdit.MaxValue = 15 
    SpinEdit.Value = def_EntryLinesCnt 
    
    Set btnSpin = CreateButton(Form, "Show", 150, 0, 50, 20, "btnSpin_OnClick") 


    Set lblPemTag = CreateLabel(Form, "Entry parsing method :", 265, 0, 130, 20) 

    Set lblPemValue = CreateLabel(Form, " ", 380, 0, 50, 20) 
    lblPemValue.Caption = "Serial" 
    
    ParseEntryMethod = pemSerial 
    Set btnPem = CreateButton(Form, "Switch", 420, 0, 50, 20, "btnPem_OnClick") 

    

    Set btnExtractFields = CreateButton(Form, "Extract Fields", 90, 0, 150, 20, "btnExtractFields_OnClick") 
    btnExtractFields.Default = True 

    Set btnClose = CreateButton(Form, "Close", 252, 0, 150, 20, "btnClose_OnClick") 
    btnClose.Cancel = True 
    
      
    Set lblMasks = CreateLabel(Form, "Usable mask fields :", 20, 0, 90, 20) 
'    Set edtMasks = CreateLabel(Form, SDB.Tools.Mask2UFText(ArrayToString(CommonTags, ", ")), 120, 0, 350, 50) 
'    edtMasks.Multiline = True 
    

  	
'******************************************************************************* 
'****   TJ START   *************************************************************
'******************************************************************************* 
'****   BORROWED FROM: NeedsAutoOrganise.vbs 
'****   AUTHOR: MoDementia 
'****   DATE  : 02/07/2006 
'****   Version: - 1.2.3
'*******************************************************************************

    Dim iCounter
    Dim NextX : NextX = 120 	'TJ - Changed from '0'
    Dim NextY : NextY = -20  	'TJ - Changed from '0'
    For iCounter = 0 To UBound(MaskTags) 
        Set btnMaskTags = CreateLabelButtonAutosize(form, SDB.Tools.Mask2UFText(MaskTags(iCounter)), NextX, NextY, "MaskTagClicked") 
        btnMaskTags.Common.Anchors = akLeft + akBottom 
    
'        TJ - Changed following line from "= btnMaskTags.Common.Left + btnMaskTags.Common.Width + 5" to "= NextX +btnMaskTags.Common.Width"
        NextX = NextX +btnMaskTags.Common.Width
        If NextX > 350 Then 
            NextX = 120 		'TJ - Changed from '0'
            NextY = NextY + 15'from 20 
        End If 
    Next 

    current_editbox = 0 
'******************************************************************************* 
'****   TJ END   ***************************************************************
'******************************************************************************* 


    NumberOfEntryLines = 0 
    Call ChangeNumberOfEntryLines(def_EntryLinesCnt) 
    
    
    Call SelectDropDownText(DataFieldsArray(0), def_TagField) 
'******************************************************************************* 
'****   TJ START   *************************************************************
'******************************************************************************* 
'    MaskTextArray(0).Text = SDB.Tools.Mask2UFText(def_TagMask) 
    MaskTextArray(0).Interf.Text = SDB.Tools.Mask2UFText(def_TagMask) 
'******************************************************************************* 
'****   TJ END   ***************************************************************
'******************************************************************************* 
    EnableStateArray(0).Checked = True 
    

    
    Form.Common.Visible = True 

End Sub 


'******************************************************************************* 
'****   
'******************************************************************************* 
Sub ChangeNumberOfEntryLines(NewNumber) 

    Form.Common.Height = 200 + NewNumber * 25 
    
    lblMasks.Common.Top = Form.Common.Height - 145 
'******************************************************************************* 
'****   TJ START   *************************************************************
'******************************************************************************* 
'    edtMasks.Common.Top = Form.Common.Height - 158
'******************************************************************************* 
'****   TJ END   ***************************************************************
'******************************************************************************* 
    lblSpin.Common.Top = Form.Common.Height - 101 
    SpinEdit.Common.Top = Form.Common.Height - 105 
    lblPemTag.Common.Top = Form.Common.Height - 101 
    lblPemValue.Common.Top = Form.Common.Height - 101 
    btnPem.Common.Top = Form.Common.Height - 105 
    btnSpin.Common.Top = Form.Common.Height - 105 
    btnExtractFields.Common.Top = Form.Common.Height - 65 
    btnClose.Common.Top = Form.Common.Height - 65 
    
    

    Dim i 
    
    If NewNumber < NumberOfEntryLines Then 
    
        For i = NewNumber To NumberOfEntryLines - 1 

            EnableStateArray(i).Common.Visible = False 
            DataFieldsArray(i).Common.Visible = False 
            MaskTextArray(i).Common.Visible = False 
            DirectionArray(i).Common.Visible = False 

        Next 
        
        ReDim Preserve EnableStateArray(NewNumber - 1) 
        ReDim Preserve DataFieldsArray(NewNumber - 1) 
        ReDim Preserve MaskTextArray(NewNumber - 1) 
        ReDim Preserve DirectionArray(NewNumber - 1) 

    Else 
    
        ReDim Preserve EnableStateArray(NewNumber - 1) 
        ReDim Preserve DataFieldsArray(NewNumber - 1) 
        ReDim Preserve MaskTextArray(NewNumber - 1) 
        ReDim Preserve DirectionArray(NewNumber - 1) 

        For i = NumberOfEntryLines To NewNumber - 1 
        
            Dim chkEnabled : Set chkEnabled = CreateCheckBox(Form, " ", 20, 10 + 25*(i+1), 15, 20, "chkEnabled" & i) 
        
            Dim ddnDataFields : Set ddnDataFields = CreateDropDown(Form, 55, 10 + 25*(i+1), 130, 20, "ddnDataFields" & i) 
            ddnDataFields.Style = csDropDownList 
            Call FillDropDownFromArray(ddnDataFields, SongDataFields) 
        
            Dim btnChangeDirection : Set btnChangeDirection = CreateButton(Form, "-->", 192, 10 + 25*(i+1), 40, 20, "btnChangeDirection_OnClick") 
            btnChangeDirection.Common.ControlName = "btnChangeDirection" & i 
    
'******************************************************************************* 
'****   TJ END   ***************************************************************
'******************************************************************************* 
'            Dim edtMaskText : Set edtMaskText = CreateEdit(Form, "", 240, 10 + 25*(i+1), 230, 15, "edtMaskText" & i) 
            Dim edtMaskText : Set edtMaskText = CreateEdit(Form, "", 240, 10 + 25*(i+1), 230, 20, "edtMaskText" & i) 
'******************************************************************************* 
'****   TJ END   ***************************************************************
'******************************************************************************* 
    
            Set EnableStateArray(i) = chkEnabled 
            Set DataFieldsArray(i) = ddnDataFields 
            Set MaskTextArray(i) = edtMaskText 
            Set DirectionArray(i) = btnChangeDirection 
        
        Next 
    
    End If 
    

    NumberOfEntryLines = NewNumber 
    
    ' Stupid, but the only way to get a redraw of the form (and so get correct displaying of the newly added controls) 
    Form.Common.Visible = False 
    Form.Common.Visible = True 

End Sub 



'***************************************************** 
'****            EVENT HANDLING METHODS           **** 
'***************************************************** 


Sub btnChangeDirection_OnClick(Button) 

    If Button.Caption = "-->" Then 
        Button.Caption = "<--" 
    Else 
        Button.Caption = "-->" 
    End If 

End Sub 


'******************************************************************************* 
'****   
'******************************************************************************* 
Sub btnPem_OnClick(btnPem) 

    If ParseEntryMethod = pemSerial Then 
        lblPemValue.Caption = "Parallel" 
        ParseEntryMethod = pemParallel 
    Else 
        lblPemValue.Caption = "Serial" 
        ParseEntryMethod = pemSerial 
    End If 

End Sub 


'******************************************************************************* 
'****   
'******************************************************************************* 
Sub btnSpin_OnClick(btnSpin) 

    Call ChangeNumberOfEntryLines(SpinEdit.Value) 

End Sub 


'******************************************************************************* 
'****   
'******************************************************************************* 
Sub btnClose_OnClick(btnClose) 

    Form.Common.Visible = False 
    Set Form = Nothing 

End Sub 


'******************************************************************************* 
'****   
'******************************************************************************* 
Sub btnExtractFields_OnClick(btnExtractFields) 


    Dim SongList : Set SongList = SDB.CurrentSongList 

    Dim Progress : Set Progress = SDB.Progress 
    Progress.Text = SDB.Localize("Extracting and applying field information...") 
    Progress.MaxValue = SongList.Count 

    Dim i, j, Song, SongOrig, MaskTextInternal 
    For i = 0 To SongList.Count - 1 
    
        Progress.Text = SDB.Localize("Extracting and applying field information... (Track " & (i+1) & " of " & SongList.Count & ")") 
        
        Set Song = SongList.Item(i) 
        Set SongOrig = Song.GetCopy 
        
        'Song.ArtistName = "" 
        'Song.AlbumArtistName = "" 
        
        For j = 0 To UBound(EnableStateArray) 
        
            If EnableStateArray(j).Checked = True Then 
            
                If DirectionArray(j).Caption = "-->" Then 
'******************************************************************************* 
'****   TJ START   *************************************************************
'******************************************************************************* 
'                    MaskTextInternal = SDB.Tools.UFText2Mask(MaskTextArray(j).Text) 
                    MaskTextInternal = SDB.Tools.UFText2Mask(MaskTextArray(j).Interf.Text) 
'******************************************************************************* 
'****   TJ END   ***************************************************************
'******************************************************************************* 
                    If ParseEntryMethod = pemSerial Then 
                        Execute("Call Song.ParseText(Song." & DataFieldsArray(j).Text & ", MaskTextInternal)") 
                    Else 'ParseEntryMethod = pemParallel 
                        Execute("Call Song.ParseText(SongOrig." & DataFieldsArray(j).Text & ", MaskTextInternal)") 
                    End If 
                Else 
'******************************************************************************* 
'****   TJ START   *************************************************************
'******************************************************************************* 
'                    MaskTextInternal = SDB.Tools.UFText2Mask(MaskTextArray(j).Text) 
                    MaskTextInternal = SDB.Tools.UFText2Mask(MaskTextArray(j).Interf.Text) 
'******************************************************************************* 
'****   TJ END   ***************************************************************
'******************************************************************************* 
                    If ParseEntryMethod = pemSerial Then 
                        Execute("Song." & DataFieldsArray(j).Text & " = Fillin(Song, MaskTextInternal)") 
                    Else 'ParseEntryMethod = pemParallel 
                        Execute("Song." & DataFieldsArray(j).Text & " = Fillin(SongOrig, MaskTextInternal)") 
                    End If 
                End If 
                
            End If 
  
        Next 

        'If Song.ArtistName = "" Then Song.ArtistName = SongOrig.ArtistName 
        'If Song.AlbumArtistName = "" Then Song.AlbumArtistName = SongOrig.AlbumArtistName 
  
        Progress.Value = i + 1 
        
        Song.UpdateAlbum 
        Song.UpdateArtist 
        Song.UpdateDB 
    Next 
    
    Call SongList.UpdateAll 

End Sub 


'******************************************************************************* 
'****   
'******************************************************************************* 
Function Fillin(Song, MaskTextInternal) 

    Fillin = MaskTextInternal 
    
    Dim key 
    For Each key In FieldDict.Keys 
        Call Execute("Fillin = Replace(Fillin, key, CStr(Song." & FieldDict(key) & "), 1, -1, 1)") 
    Next 

End Function 


'******************************************************************************* 
'****   
'******************************************************************************* 
Function ArrayToString(SourceArray, SepChar) 

    ArrayToString = SourceArray(0) 
    Dim i 
    For i = 1 To UBound(SourceArray) 
        ArrayToString = ArrayToString & SepChar & SourceArray(i) 
    Next 
    
End Function 


'***************************************************** 
'****          CONTROLS UTILITY METHODS           **** 
'***************************************************** 

' BorderStyle constants 
const bsNone = 0   'No border 
const bsSizeable = 2   'Standard window (resizable) 
const bsDialog = 3   'Dialog window (not resizable) 
const bsToolWindow = 4   'Toolwindow (not resizable) 
const bsSizeToolWin = 5   'Toolwindow (resizable) 


' Position constants (for Forms) 
const poDesigned = 0    'Position and size specified by Left, Top, Width and Height 
const poDefault = 1    'Position and size determined by the operating system 
const poScreenCenter = 4 'Centered on the screen 


' DropDown Style constants 
Const csDropDown = 0     'DropDown can be edited 
Const csDropDownList = 2 'DropDown cannot be edited (user can only select from a list of values) 


Function CreateForm(Caption, X, Y, Width, Height, BorderStyle, FormPosition, StayOnTop, SavePositionName) 

    Set CreateForm = SDB.UI.NewForm 
    CreateForm.Caption = Caption 
    CreateForm.Common.SetRect X, Y, Width, Height 
    CreateForm.BorderStyle = BorderStyle 
    CreateForm.FormPosition = FormPosition 
    CreateForm.StayOnTop = StayOnTop 
    CreateForm.SavePositionName = SavePositionName 

End Function 


Function CreateDropDown(Owner, X, Y, Width, Height, ControlName) 

    Set CreateDropDown = SDB.UI.NewDropDown(Owner) 
    CreateDropDown.Common.SetRect X, Y, Width, Height 
    CreateDropDown.Common.ControlName = ControlName 

End Function 


'******************************************************************************* 
'****   TJ START   *************************************************************
'******************************************************************************* 
    Sub textBox1_Enter(textBox1)
        ' If the TextBox contains text, change its foreground and background colors.
        If textBox1.Text <> [String].Empty Then
            textBox1.ForeColor = Color.Red
            textBox1.BackColor = Color.Black
            ' Move the selection pointer to the end of the text of the control.
            textBox1.SelectAll
        End If
    End Sub 'textBox1_Enter


Sub edtMaskText_OnClick(edtMaskText)

    SDB.MessageBox "HEY! SHOW ME SOMETHING!!!", mtInformation, Array(mbOK) 
    Dim i
    For i = 0 to NumberOfEntryLines - 1 
        
        If MaskTextArray(i) = edtMaskText Then 
            current_editbox = i 
            Exit For 
        End If 
    Next   

End Sub 

Function CreateEdit(Owner, Text, X, Y, Width, Height, ControlName) 

    Set CreateEdit = SDB.UI.NewActiveX(Owner, "Forms.TextBox.1") 
    CreateEdit.Interf.HideSelection = False 
    CreateEdit.Interf.BorderStyle = 1 ' Forms.TextBox.1 
    CreateEdit.Interf.BorderColor = &H888888  
    CreateEdit.Interf.Text = Text 
    CreateEdit.Common.SetRect X, Y, Width, Height 	
    CreateEdit.Common.ControlName = ControlName 
'    CreateEdit.Interf.BackColor = &H000000 
'    CreateEdit.Interf.ForeColor = &HEFEFEF 
    Script.RegisterEvent CreateEdit, "OnClick", "edtMaskText_OnClick" 
    Script.RegisterEvent CreateEdit.Common, "OnClick", "edtMaskText_OnClick" 
'    Script.RegisterEvent CreateEdit.Common, "OnEnter", "edtMaskText_OnEnter" 
'    Script.RegisterEvent CreateEdit.Common, "OnSelect", "edtMaskText_OnEnter" 
'    Script.RegisterEvent CreateEdit.Common, "OnEdited", "edtMaskText_OnEnter" 
'    Script.RegisterEvent CreateEdit.Common, "OnGotFocus", "edtMaskText_OnEnter" 
End Function 
'Function CreateEdit(Owner, Text, X, Y, Width, Height, ControlName) 
'
'    Set CreateEdit = SDB.UI.NewEdit(Owner) 
'    CreateEdit.Text = Text 
'    CreateEdit.Common.SetRect X, Y, Width, Height 
'    CreateEdit.Common.ControlName = ControlName 
'
'End Function 

'******************************************************************************* 
'****   TJ END   ***************************************************************
'******************************************************************************* 

  
Function CreateSpinEdit(Owner, X, Y, Width, Height, ControlName) 

    Set CreateSpinEdit = SDB.UI.NewSpinEdit(Owner) 
    CreateSpinEdit.Common.SetRect X, Y, Width, Height 
    CreateSpinEdit.Common.ControlName = ControlName 
    
End Function 


Function CreateButton(Owner, Caption, X, Y, Width, Height, OnClickHandler) 

    Set CreateButton = SDB.UI.NewButton(Owner) 
    CreateButton.Caption = Caption 
    CreateButton.Common.SetRect X, Y, Width, Height 
    If OnClickHandler <> "" Then 
        Script.RegisterEvent CreateButton.Common, "OnClick", OnClickHandler 
    End If 

End Function 


Function CreateLabel(Owner, Caption, X, Y, Width, Height) 

    Set CreateLabel = SDB.UI.NewLabel(Owner) 
    CreateLabel.Caption = Caption 
    CreateLabel.Common.SetRect X, Y, Width, Height 

End Function 


Function CreateCheckBox(Owner, Caption, X, Y, Width, Height, ControlName) 

    Set CreateCheckBox = SDB.UI.NewCheckBox(Owner) 
    CreateCheckBox.Caption = Caption 
    CreateCheckBox.Common.SetRect X, Y, Width, Height 
    CreateCheckBox.Common.ControlName = ControlName 
    
End Function 


Sub SelectDropDownText(DropDown, Text) 

    Dim i 
    For i = 0 To DropDown.ItemCount - 1 
        If DropDown.ItemText(i) = Text Then 
            DropDown.ItemIndex = i 
            DropDown.Text = Text 
            Exit For 
        End If 
    Next 
    
End Sub 


Sub FillDropDownFromArray(DropDown, SourceArray) 

    Dim i 
    For i = 0 To UBound(SourceArray) 
        DropDown.AddItem SourceArray(i) 
    Next 

End Sub 


'******************************************************************************* 
'****   TJ START   *************************************************************
'******************************************************************************* 
'****   BORROWED FROM: NeedsAutoOrganise.vbs 
'****   AUTHOR: MoDementia 
'****   DATE  : 02/07/2006 
'****   Version: - 1.2.3
'*******************************************************************************
Function CreateLabelButtonAutosize(Owner, Caption, X, Y, OnClickHandler) 

  Set CreateLabelButtonAutosize = SDB.UI.NewLabel(Owner) 
  CreateLabelButtonAutosize.Caption = RTrim(Caption) 
  CreateLabelButtonAutosize.Autosize = True
  CreateLabelButtonAutosize.Common.Left = X 
  CreateLabelButtonAutosize.Common.Top = Y 
  If OnClickHandler <> "" Then 
    Script.RegisterEvent CreateLabelButtonAutosize.Common, "OnClick", OnClickHandler 
  End If 

End Function 

 
'******************************************************************************* 
'****   BORROWED FROM: NeedsAutoOrganise.vbs 
'****   AUTHOR: MoDementia 
'****   DATE  : 02/07/2006 
'****   Version: - 1.2.3
'*******************************************************************************
Sub MaskTagClicked(Button) 

  If MaskTextArray(current_editbox).Interf.SelStart = 0 Then
    MaskTextArray(current_editbox).Interf.SelText = Button.Caption 
  Else
    MaskTextArray(current_editbox).Interf.SelText = def_TagSeparator & Button.Caption
  End If

End Sub 
'******************************************************************************* 
'****   TJ END   ***************************************************************
'******************************************************************************* 


'***************************************************** 
'****             EXTRA ENUMERATIONS              **** 
'***************************************************** 

Dim CommonTags : CommonTags = Array("%A", "%L", "%S", "%G", "%T", "%Y", "%X", "%R", "%C", "%M", "%B", "%U", "%V", "%W", "%P", "%F") 

'******************************************************************************* 
'****   TJ START   *************************************************************
'******************************************************************************* 
'****   BORROWED FROM: NeedsAutoOrganise.vbs 
'****   AUTHOR: MoDementia 
'****   DATE  : 02/07/2006 
'****   Version: - 1.2.3
'*******************************************************************************
'Dim MaskTags : MaskTags = Array("%A", "%L", "%S", "%G", "%T", "%Y", "%R", "%C", "%M", "%B", "%U", "%V", "%W")
Dim MaskTags : MaskTags = Array("%A", "%L", "%S", "%G", "%T", "%Y", "%X", "%R", "%C", "%M", "%B", "%U", "%V", "%W", "%P", "%F") 

' Anchors constants (control to which borders of the parent control the control is sticked) 
Const akLeft = 1     'Distance from the left border of the parent is constant 
Const akTop = 2       'Distance from the top border of the parent is constant 
Const akRight = 4    'Distance from the right border of the parent is constant 
Const akBottom = 8    'Distance from the bottom border of the parent is constant 
'******************************************************************************* 
'****   TJ END   ***************************************************************
'******************************************************************************* 




' Enumeration of the most important fields in the SongData object 
Dim SongDataFields : SongDataFields = Array( _ 
        "AlbumArtistName", _ 
        "AlbumName", _ 
        "ArtistName", _ 
        "Author", _ 
        "Band", _ 
        "Bitrate", _ 
        "BPM", _ 
        "Comment", _ 
        "Conductor", _ 
        "Copyright", _ 
        "Custom1", _ 
        "Custom2", _ 
        "Custom3", _ 
        "Encoder", _ 
        "Genre", _ 
        "InvolvedPeople", _ 
        "Lyricist", _ 
        "Lyrics", _ 
        "MediaLabel", _ 
        "Mood", _ 
        "MusicComposer", _ 
        "Occasion", _ 
        "OriginalArtist", _ 
        "OriginalLyricist", _ 
        "OriginalTitle", _ 
        "OriginalYear", _ 
        "Publisher", _ 
        "Quality", _ 
        "Rating", _ 
        "Tempo", _ 
        "Title", _ 
        "TrackOrder", _ 
        "Year") 
        
Dim FieldDict : Set FieldDict = CreateObject("Scripting.Dictionary") 
With FieldDict 
  .Add "%A", "ArtistName" 
  .Add "%C", "Author" 
  .Add "%G", "Genre" 
  .Add "%L", "AlbumName" 
  .Add "%M", "BPM" 
  .Add "%R", "AlbumArtistName" 
  .Add "%S", "Title" 
  .Add "%T", "TrackOrder" 
  .Add "%U", "Custom1" 
  .Add "%V", "Custom2" 
  .Add "%W", "Custom3" 
  .Add "%Y", "Year" 
End With
Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm

Post by Steegy »

:lol: Yeah, the NeedsAutoOrganise script borrowed from the script I meant in my previous post. So I was going to use the same code essentially.
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
Eyal
Posts: 3116
Joined: Sun Jun 26, 2005 9:27 am
Location: Québec

Post by Eyal »

Thanks tj_junk, thanks Steegy.
It saved my life. Now it's lot more easy to use, no matter the language.

Cheers
Skins for MediaMonkey: Cafe, Carbon, Helium, Spotify, Zekton. [ Wiki Zone ].
Eyal
Posts: 3116
Joined: Sun Jun 26, 2005 9:27 am
Location: Québec

Post by Eyal »

Hi again!

I just noticed that it's not possible to insert <tags> by clicking on them into line2 and so on. It don't detect the caret focus other than line1.

Is it complicated to implement?

Thank you.
Skins for MediaMonkey: Cafe, Carbon, Helium, Spotify, Zekton. [ Wiki Zone ].
Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm

Post by Steegy »

It probably isn't, but I can't possibly do this now. I'm still on holiday (already had 1,5 weeks, and now another week) and only have some short access to internet. tj_junk, can you do this?
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
Post Reply