Jump to content

Please Help A Beaten Man (dll Help)


Recommended Posts

Hi all - Long time lurker, first time caller - and I need help!

I am trying to create a rather customized Mp3 editor which allows me to read from and write to the 'content group' field of an mp3's ID3 tag. I have found 2 .dll files which (I believe) will allow me to access these fields, however I have been unsucessful after the many, many hours of trial and error and extensive googling, not to mention scouring these forums. I'm looking for any pointers, suggestions or examples you may wish to throw my way.

I initially found this thread which contained some good beginner's tips from DaleHohm, however the dll in use there (CDDBControl) does not appear to have the functions I need - only contains methods to read the common tags such as artist, track title, etc.

As mentioned, I found 2 DLLs - "ID3COM.DLL", found here... and "UltraID3Lib.dll", found here.

I had preferred to use the second one (Ultra) as the documentation was a bit more robust and it seems to be actively maintained and supported. ID3COM no longer is supported based on the link above.

Now, as far as playing around with both of these DLLs - I have read up about using regsvr32 to register the DLL, and then use the MS OLE viewer to look at the DLLs and see what the proper function names are. (And yes, I've read through COM/DLL section of the the beta manual many times over.)

With UltraID3, I cannot register it with regsvr32. The webpage itself mentions that it is .Net DLL for use with VB.net. I take it this is different than ActiveX COM or whatever 'normal' DLLs Autoit might expect to work with or have loaded via regsvr32.

That brought me to ID3COM - this loads into regsvr32 just fine. But, for the life of me, I can't seem to do anything with it. The documentation on the (no longer updated or supported) webpage leaves much to be desired.

Combine the frustration of the above 2 scenarios with the fact that I'm still not sure what the difference is between "ObjCreate("foo.bar")" vs. "DllCall($dll, "this", "that")".

So, my questions:

- At what point is each appropriate? My line of thinking, and perhaps very misguided, was that you use ObjCreate if/when you have a DLL registered via regsvr32, and DllCall when you either cannot or do not want to register a DLL.

- Is the UltraID3 dll usable with Autoit at all? Can we use ".net" kind of DLLs?

- Could anyone possibly point me in the right direction of where I'm trying to go? Are there other avenues I may have overlooked? Basically, all I want is the ability to write to (and read from) the 'content group' field of the ID3 tag. Apparently this is referred to as "TIT1" as a four-character code used in ID3-Tag-dome.

I'm just really stumped and this is something I've been working on and off for weeks now. Basically I've spent entire evening(s) on it just to get frustrated and forget about it for a while, then come back just to get frustrated again. Any help or guidance would be immensely appreciated.

A bit of background, if you must know what I'm up to:

I have thousands of MP3s. I recently got an iPod, which made me start using iTunes. I read that some people were organizing their Mp3s in such a way that was very selective, far above and beyond that of simply tagging your Mp3 in a genre. Using Smart Playlists and a variety of tags in the "Content Group" field (which is the "Grouping" field in iTunes), you could create highly customized playlists. So instead of making a playlist that plays the "Rock" genre, I could create a playlist that plays only "90's grunge rock with female vocals" or "Funk from the 60's with guitar solos". If you are into electronic music, you'll know what I'm talking about. 90% of my collection is "Electronica" but the styles are far-reaching that the standard 'genre' tag just can't handle. (The different types of "house" music alone is mind boggling.) So, for instance, if I have the song "Funkytown", I could label it with: "80s;Funky;Disco;vocals:female;synthesizers;mood:nostalgic;mood:party". I could create a "80's party mix" or "Funky Females" or "Memory Lane" smart playlist and this song would appear dynamically in all of those lists.

There are ID3 editors already out there that allow you to edit the "Content Group" field - however it is always manual. I could do this in iTunes, but again, it's all a manual process. Open a track, enter the text string(s) you wish to tag it with, hope there are no typos, and move on to the next track and repeat the process. This would take forever.

I created an Autoit script with GUI that allowed me to create the tags I want that then show in a checkbox list. It piggybacked on top of a freeware ID3 editor which allowed for 'content group' editing and allowed me to control the application via 'controlclick', 'controlsettext', etc. Simply check off the tags I want applied to the MP3 (with my GUI), click a button and it saves the data (using the 'real' ID3 tagging app), then goes to the next mp3, ready to be tagged.

This works well in the automation department, but I hate the idea of bastardizing someone else's program with my automation overlay - especially when I know that AutoIt can do this, just that I am apparently too inept to get it to work. Not to mention this isn't a very 'distribution-friendly' application.. I'd feel pretty stupid trying to share this with people and saying "well, you're going to need this other application for it to work".

Thanks again for any help you can provide!

And on a side note - I love AutoIt! Until now I haven't needed support beyond the help/chm file. I've made a few applications for work which have helped automate some repetitive tasks we do in my position.

Link to comment
Share on other sites

This works well in the automation department, but I hate the idea of bastardizing someone else's program with my automation overlay - especially when I know that AutoIt can do this, just that I am apparently too inept to get it to work. Not to mention this isn't a very 'distribution-friendly' application.. I'd feel pretty stupid trying to share this with people and saying "well, you're going to need this other application for it to work".

If that's the way you feel, would iTunes automation not be your style? It would require iTunes to work, but no other outside program (it uses the COM aspect of iTunes). I can help you out if you're willing to do it with iTunes. If not, I'm not sure about the rest of the stuff (might just have to do some more research...).

Link to comment
Share on other sites

If that's the way you feel, would iTunes automation not be your style? It would require iTunes to work, but no other outside program (it uses the COM aspect of iTunes). I can help you out if you're willing to do it with iTunes. If not, I'm not sure about the rest of the stuff (might just have to do some more research...).

I thought of that. I wouldn't have a problem with this being a 'plugin' of sorts that works on top of Itunes, since that's really the application I'm developing it to work with.

Slight problem - the iTunes software (for windows, anyways) appears to be locked down tight. Itunes uses CDDBApple.dll or something along those lines - it is locked, somehow - such that I can't browse the DLL structures in OLE viewer.

As for the application itself, that too seems to be inaccessible. I tried using both the Autoit window viewer tool as well as WinSpy++, neither of them seem to reveal any controls that I can use to automate.

I know that Itunes under MacOS is fully scriptable with AppleScript - in fact people using the Mac version of Itunes have made exactly what I am trying to do here. To the best of my knowledge, there is no way to script or otherwise enhance/modify the Itunes application under windows.

Are you aware of a way to get around this in Itunes for Windows, or were you referring to the Mac version?

Thanks for your help!

Link to comment
Share on other sites

probably this one...

ID3COM.DLL

Lar.

Thanks.. I'll focus on ID3COM. Is there a way to see all of the functions/methods (I'm not sure what the appropriate term for them are) that are available for use via AutoIt? I know of the OLE viewer - was wondering if Autoit has any ability to 'autodiscover' the types of functions available to it from any given DLL.

Thanks -

Link to comment
Share on other sites

On second thought I am reading about CDDBControl... and all you do is RegSvr32 it and the code is like

which can be translated to (beta) AutoIt. I am looking for official type docs on methods and properties and stuff now...

Lar.

Wow, thanks. I did find some info on CDDBControl, but nothing indicating that I can access the "Content Group" field, which is what I'm really after. If CDDBControl *can* do that, it would be perfect.

After green's suggestion, I searched the forums for "Itunes" and it appears there is an SDK kit out that tells you all the commands you can use with the itunes COM control. I'm looking into that now - and it may work, but it seems all controls are based on what you're doing within the Itunes application. IE, I see no command to open (or even select) an mp3 programmatically, you would need to select a file or files within Itunes and only then could you get the list of selected files to Autoit.

I don't see how I could 'target' a specific MP3 to apply my changes to it. The COM support does allow me to read from and write to the 'grouping' (content group) field, I just see no way at this point to tell it which file I want to work with, short of manually selecting that file in Itunes.

Link to comment
Share on other sites

Wow, thanks. I did find some info on CDDBControl, but nothing indicating that I can access the "Content Group" field, which is what I'm really after. If CDDBControl *can* do that, it would be perfect.

After green's suggestion, I searched the forums for "Itunes" and it appears there is an SDK kit out that tells you all the commands you can use with the itunes COM control. I'm looking into that now - and it may work, but it seems all controls are based on what you're doing within the Itunes application. IE, I see no command to open (or even select) an mp3 programmatically, you would need to select a file or files within Itunes and only then could you get the list of selected files to Autoit.

I don't see how I could 'target' a specific MP3 to apply my changes to it. The COM support does allow me to read from and write to the 'grouping' (content group) field, I just see no way at this point to tell it which file I want to work with, short of manually selecting that file in Itunes.

if they're public functions/methods, just call them with the filename. when you select the file in itunes, it's just retrieving that filename from a property that's set by selecting the file. so all you have to do is figure out how you can set that property programatically, either by automating the file selection (booo) or by passing a file name to the function.

***edit*** disregard if you want, i'm a little over medicated right now, and that didn't even make sense to me right after writing it. when i get my computer over to my girlfriend's (tonight or tomorrow) i'll work something up for you.

Edited by cameronsdad
Link to comment
Share on other sites

if they're public functions/methods, just call them with the filename. when you select the file in itunes, it's just retrieving that filename from a property that's set by selecting the file. so all you have to do is figure out how you can set that property programatically, either by automating the file selection (booo) or by passing a file name to the function.

***edit*** disregard if you want, i'm a little over medicated right now, and that didn't even make sense to me right after writing it. when i get my computer over to my girlfriend's (tonight or tomorrow) i'll work something up for you.

That would be great. I'm not sure what you mean by calling the function with the filename.. I've tried a number of things and keep getting errors with "Object expected", so apparently I'm not building the commands properly.

For instance - looking at the chm file for Itunes COM support, I see that '.Grouping()' is probably the function I want to using.

I tried this, but get an error:

$iTunesx = ObjCreate("iTunes.application")

$file = "c:\myfile.mp3"

$group = $iTunesx.Grouping($file)

MsgBox(0,"",$group)
Link to comment
Share on other sites

  • Moderators

when i get my computer over to my girlfriend's (tonight or tomorrow) i'll work something up for you.

:)

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Here's a little bit of stuff I threw together to help out. First, it collects all the mp3 files on your computer and stores the locations in text files (AllMp3scDrive.txt for c, etc), then after that is all done (which will probably take a fair amount of time) it will create an itunes object, tell you how many tracks are in your library, give you the first 20 songs (artist, name, and current grouping) in the library, and then create a text file of all the songs on your computer but not in your library. That file will help for later if you want to add them to your library or edit them separately.

Note: to set grouping, use $TrackObject.Grouping = "newgroup", where $TrackObject is the object of a track (not in the code, just an example). Also notice how none of these are actually functions... you don't actually pass things to the itunes objects, you just call them or set values to them.

$Drives = DriveGetDrive ("FIXED")
For $i = 1 To $Drives[0]
    If Not FileExists ("C:\AllMp3s" & StringLeft($Drives[$i], 1) & "Drive.txt") Then
        RunWait (@ComSpec & " /c dir " & $Drives[$i] & "\*.mp3 /s /b > C:\AllMp3s" & StringTrimRight ($Drives[$i], 1) & "Drive.txt", @WorkingDir, @SW_HIDE)
    EndIf
Next
; all mp3's are in the files

Global $MusicOnDrives[$Drives[0]+1]
$MusicOnDrives[0] = $Drives[0]

$oITunes = ObjCreate("iTunes.Application")
If @error Then
    Msgbox (0,"iTunes","Error Getting an iTunes Object. Error code: " & Hex (@error, 8))
    Exit
EndIf
$LibraryPlaylist = $oITunes.LibraryPlaylist
$LibraryTracks = $LibraryPlaylist.Tracks
MsgBox (0, "Count", "There are currently: " & $LibraryTracks.Count & " tracks in your library.")
$msg = ""
For $i = 1 To 20
    $msg &= $LibraryTracks.Item($i).Artist & " - " & $LibraryTracks.Item($i).Name & " - " & $LibraryTracks.Item($i).Grouping & @CRLF
Next
MsgBox (0, "Artist - Name - Grouping", $msg)
$msg = ""
For $i = 1 To $MusicOnDrives[0]
    $MusicOnDrives[$i] = FileRead ("C:\AllMp3s" & StringLeft($Drives[$i], 1) & "Drive.txt")
Next
For $i = 1 To $LibraryTracks.Count
   ; assuming c is index 1 (it should be); ascii A = 65, ascii C = 67, index for c = ascii - 66
    $driveletter = StringLeft ($LibraryTracks.Item($i).Location, 1)
    $driveletter = StringUpper ($driveletter)
    $index = Asc ($driveletter) - 66
    If Not StringInStr ($MusicOnDrives[$index], $LibraryTracks.Item($i).Location) Then
        FileWriteLine("C:\NotInLibrary.txt", $LibraryTracks.Item($i).Location)
    EndIf
Next
MsgBox (0, "Not in library", $msg)
$oITunes = 0
Link to comment
Share on other sites

when i get my computer over to my girlfriend's (tonight or tomorrow) i'll work something up for you.

I suspect he's wondering why, if this girl exists :) you would want to do anything related to a computer in her presence....

edit: Duck and Cover :mellow:

Edited by flyingboz

Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

Link to comment
Share on other sites

Here's a little bit of stuff I threw together to help out. First, it collects all the mp3 files on your computer and stores the locations in text files (AllMp3scDrive.txt for c, etc), then after that is all done (which will probably take a fair amount of time) it will create an itunes object, tell you how many tracks are in your library, give you the first 20 songs (artist, name, and current grouping) in the library, and then create a text file of all the songs on your computer but not in your library. That file will help for later if you want to add them to your library or edit them separately.

Note: to set grouping, use $TrackObject.Grouping = "newgroup", where $TrackObject is the object of a track (not in the code, just an example). Also notice how none of these are actually functions... you don't actually pass things to the itunes objects, you just call them or set values to them.

Thanks green, this is extremely helpful! I've been playing around with this and a few other examples I've found around the net since your previous post. I think I'm getting the hang of it now, but running into a logic error relating to results (or lack thereof) I'm getting from Itunes. I'm going to post that in a new thread though, as it's a different issue than the original post.

Thanks again!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...