Admin File Management
Autoit Programmer's Aids
Admin Rights & Shortcuts For All
CyberSlug's - GuiBuilder (update)
A place that links to many useful Scripts & Scraps
Time Calculator v1.5 (previous number of downloads: 79) (see My Other Posts for details)
Simple CDPlayer v1.3 (previous number of downloads: 282)
I've made a simple little CD player program, as a precursor to a more complex CD database & CD cover program. I've previously made versions in both VB6 & VB for applications, which now need updating, and as I haven't used VB6 for well over a year (the wonderful AutoIt 3 being that good), I thought that using AutoIt instead, would be the better way to go.
However I have a little problem, that's turned into a big problem for me - I cannot seem to modify my original VB code, to get the Unique ID code for every Audio CD. I'm trying to use the command mciSendString for 'Winmm.dll", but certain areas of VB leave me somewhat mystified ... making sense of VB has always been a sore point with me, and is one of the many reasons, why I turned to AutoIt 3 for all my programming needs.
Here then, is my code for the simple little CD player program, followed by the VB code I used in my original VB programs. If anyone can enlighten me, about where I'm going wrong, it would be greatly appreciated - LazyCat whom I've admired from afar, has helped me many times in the past - dll's, VBScript, etc.
For any newbie's interested in using my code (do so by all means), just take into account that it was quickly whipped together, with no true error checking, other than some of the obvious. There is for instance, not many checks to see if the drive is ready - these should be added (at the very least). There are other CD or Media player examples in the forum, that are worth checking out. Some of the code is not working with my Pioneer 110 dvd burner - the mute doesn't work and pause does not display paused (only stopped). I haven't created a track time - played/remaining routine, etc. The most important thing to note perhaps, is the static CD drive - I haven't implemented a drive check routine, so if your drive is not "E:\" (!E: ), then either create a routine (or implement a manual selection), or just replace it with the correct drive letter.
Original VB Code that I adapted for my VB programs, as commented
by the original author/programmer (Edy Hinzen) -
Calculating cdplayer.ini id by algorithm If you want to calculate the id - instead of using GetVolumeInformation - you may try this algorithm. For Delphi sample and algorithm explanation, see here. (http://www.hinzen.de/cdplayer/samples/sample05.html) ' Basic sample © Edy Hinzen 2001 Declare Function mciSendString Lib "WinMM" Alias "mciSendStringA" _ (ByVal lpszCommand As String, _ ByVal lpszString As String, _ ByVal Stringlen As Integer, _ ByVal hWnd As Long) As Integer Function MilliSecsToFrames(milliSecs As Long) As Long Const FRAME_PER_SEC = 75 Dim result As Long result = milliSecs * FRAME_PER_SEC \ 1000 ' Did the division have a reminder? Then increment result by 1 If milliSecs <> (result * 1000 \ FRAME_PER_SEC) Then result = result + 1 MilliSecsToFrames = result End Function Sub MCIDemo() Dim iResult As Integer Dim sResult As String * 30 Dim Min, Sec, frames As Long Dim dwTemp As Long Dim cdTotalTracks As Integer Dim magicNumb As Integer Dim cdLength As Long Dim driveLetter$ driveLetter = "!P: " ' in this example, we use drive P:\ 'driveLetter = "" ' in this example, we use the first drive found iResult = mciSendString("Open CDAudio" & driveLetter & "alias CDAudio shareable wait", "", 0, 0) iResult = mciSendString("Status CDAudio Media Present wait", sResult, Len(sResult), 0) iResult = mciSendString("Status CDAudio Number of Tracks", sResult, Len(sResult), 0) cdTotalTracks = Val(sResult) iResult = mciSendString("Set CDAudio time format tfmsf wait", 0, 0, 0) dwTemp = 0 magicNumb = 0 For trackNum = 1 To cdTotalTracks iResult = mciSendString("Status CDAudio Position Track " & Str(trackNum), sResult, Len(sResult), 0) Min = Val(Mid$(sResult, 1, 2)) Sec = Val(Mid$(sResult, 4, 2)) frames = Val(Mid$(sResult, 7, 2)) dwTemp = dwTemp + ((Min * &H10000) + (Sec * &H100) + frames) If (trackNum = 1) And (cdTotalTracks = 2) Then magicNumb = frames Next trackNum If cdTotalTracks < 3 Then iResult = mciSendString("set CDAudio time format Milliseconds wait", 0, 0, 0) iResult = mciSendString("Status CDAudio Length", sResult, Len(sResult), 0) cdLength = MilliSecsToFrames(Val(sResult)) dwTemp = dwTemp + magicNumb + cdLength End If MsgBox Hex(Str(dwTemp)) ' display result iResult = mciSendString("Close CDAudio", "", 0, 0) End Sub back to Q&A (http://www.hinzen.de/cdplayer/q-and-a.html) Last upload: 03/22/2004 14:53:04 Last upload: Mon, 23 Jun 2003 07:00:06 GMT
I've developed many, many AutoIt programs - starting with version 2.63, which I've not released to the public yet - mostly because I'm still honing my programming skills, but also because I've not got a suitable web page up and running yet. Whenever I've needed a program or a better program, I've virtually always been able to create it with AutoIt 3.
I'm so enthused with AutoIt 3, that I often have this dream about starting a programming magazine, based solely on AutoIt. This is particularly appealing to me, because of the phenominal success I've had using the program, and because of issues I have with my current employment & health. I really appreciate what Jon and the other members of the AutoIt team have done, and also consider the Forum, to be one of the best of it's kind. Not being particularly financial at this time, I cannot give AutoIt the support it needs and deserves - but if I could I would, and I'd like to see it out there, being used by the more mainstream, and getting all the
accolades it truly deserves.
I often come across programs, that other third parties have made GUI's for, and find myself thinking that it could be done better using AutoIt ... in particular these command-line driven programs are often developed by Linux users - cd burning, mp3, etc.
I'm quite a newb, when it comes to Linux (though I do have Ubuntu up and running alongside XP - partitions & boot menu ... haven't really used it much yet). Not being versed in the more complex programming languages, I have no idea what it would take to get AutoIt into the Linux world, and whether it would be worth it. It has a certain appeal though, because of the clear and precise way AutoIt is explained and implemented - by far the best I've ever seen or used. I'd even like to see it be to Open Office or similar, what VB is to Microsoft Office ... now that would be a slice of heaven.
Tim aka theSaint
Edited by TheSaint, 20 February 2009 - 03:32 AM.