Jump to content
Sign in to follow this  
rasa

Recognizing disc type

Recommended Posts

What way I could determine when an Audio CD is inserted into CD-ROM drive?

Is there any script made already?

Share this post


Link to post
Share on other sites

You could probably make a search for CDA-files (isn't it ?) on your

CD-drive and place it in a loop. Or something.. :lmao:

Share this post


Link to post
Share on other sites

You could probably make a search for CDA-files (isn't it ?) on your

CD-drive and place it in a loop. Or something.. :lmao:

<{POST_SNAPBACK}>

Correct. Audio CDs have the extension of .CDA (Compact Disc Audio) for the tracks.

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites

What way I could determine when an Audio CD is inserted into CD-ROM drive?

Is there any script made already?

<{POST_SNAPBACK}>

Here ya go Rasa. Let me know how it performs. audiocd.au3

:lmao:

I tested it and it worked fine. Only glitch I can see is if you insert a cd b4 you run it and run it right away it won't work. you have to let the computer "get up to date" (i.e. wait till that loading light is off"...you can just put a sleep in your main code if you want..

i've given you a choice of which function to use:

one is general: ANY cd rom has an audio cd it returns true

2nd is specific: drive you supply has audio cd it returns true

(w/ example) you can just rip out the function I created and put it in your own

code. I'd include the global const''s i've used. They're need by the function, plus they're useful for other coding uses.

Global const $TRUE=1Global const $FALSE=0local $findAudiolocal $cddrive="e:"$findAudio=_IsAudioCD()if $findAudio then msgbox(0,"","You have an Audio CD in your cd-rom")if _IsAudioCDdrive($cddrive) then msgbox(0,"",$cddrive&" has an audio cd in it")Func _IsAudioCD();search through all the drives to find a cd rom drive,;then see if it has an audio cd in there.; TRUE = found audio cd; FALSE = didn't find audio cd, or user doesn't have a cd-rom drive  ;get all CDROM drives   $var = DriveGetDrive( "CDROM" ) ;if we found 1 or more cdrom drives then check if there's an    ;audio cd in any of them    If NOT @error Then      For $i = 1 to $var[0]           ;change the path ---- used to tell FileFindFirstFile where to search            ;change it to our cd-rom            FileChangeDir ( $var[$i]&"\" )          ; if find a .cda file then means we got an audio cd         $search = FileFindFirstFile("*.cda")            ; Check if the search was successful            ; return appropriate value as specified in func description         If $search = -1 Then                Return $FALSE           Else                Return $TRUE            EndIf       Next    Else        return $FALSE   EndIfEndFuncFunc _IsAudioCdDrive($drive);$drive MUST be only drive w/colon otherwise causes error; e.g. drive e is the one you're checking then ;$drive value should be "e:"    ;change working path for FileFindFirstFile to the $drive sent plus \    FileChangeDir ( $drive &"\" )   ; if find a .cda file then means we got an audio cd $search = FileFindFirstFile("*.cda")    ; Check if the search was successful    ; return appropriate value as specified in func description If $search = -1 Then        Return $FALSE   Else        Return $TRUE    EndIfEndFunc[code=auto:0]


            
                


    Edited  by closeupman
    
    

            
        

        
            
                
                    

        
        
            
                
                
                    
                
            
            
            
        
    

                
            
            
                
                    
                    
                    
                
                
                    
                
            
        

        
    

    
        
            Share this post
            
            Link to post
            
            
            

            
                Share on other sites
                

    
        
            

    

        
            

    

        
            

    

        
            

    

        
    

            
        
    

    

                    
                
                    
                    
                    






    

    
        
            

rasa
              

    
        
    
             0
    
        
    

        
        
            


    
        
    

        
    
    
        

rasa
               

    
        
    
             0
    
        
    


        
            
                Seeker
            
            

            
                


    
        
    

            
            Members
            
            
                

    
        
    
             0
    
        
    

                5 posts
                
                

            
        
    
    
        


    

    
        
            
                
                
                
                    
                
                
            
        

        
            Posted 
            
                
                
            
        
    

    


    
        
        
            Thank you all!
Really fast answers! I'm surprised.
Gonna try it soon as I get home!


            
        

        
            
                
                    

        
        
            
                
                
                    
                
            
            
            
        
    

                
            
            
                
                    
                    
                    
                
                
                    
                
            
        

        
    

    
        
            Share this post
            
            Link to post
            
            
            

            
                Share on other sites
                

    
        
            

    

        
            

    

        
            

    

        
            

    

        
    

            
        
    

    

                    
                
                    
                    
                    






    

    
        
            

closeupman
              

    
        
    
             0
    
        
    

        
        
            


    
        
    

        
    
    
        

closeupman
               

    
        
    
             0
    
        
    


        
            
                Wayfarer
            
            

            
                


    
        
    

            
            Active Members
            
            
                

    
        
    
             0
    
        
    

                87 posts
                
                

            
        
    
    
        


    

    
        
            
                
                
                
                    
                
                
            
        

        
            Posted 
            
                
                
            
        
    

    


    
        
        
            Thank you all!Really fast answers! I'm surprised.Gonna try it soon as I get home!<{POST_SNAPBACK}>Yw....I update my code..and made it one function. The return value of the function is still the same, however you put a variable to receive the drive letter which will be returned with the function call if it is true. You DON'T have to specify anything. It is only there to RECEIVE a value.;used for demonstration purposes only
local $foundAudioAudio,$thisdrive

;DEMO USE of Function
$foundAudioCD=_IsAudioCD($thisdrive)

if $foundAudioCD then msgbox(0,"","You have an Audio CD in your " &$thisdrive&" drive")


Func _IsAudioCD(ByRef $whatdrive)
;search through all the drives to find a cd rom drive,
;then see if it has an audio cd in there.
; TRUE = found audio cd,
; and returns the drive letter of the drive that had the audio cd in $whatdrive

; FALSE = didn't find audio cd, or user doesn't have a cd-rom drive

;used for return values
Local const $TRUE=1
Local const $FALSE=0

;get all CDROM drives
    $var = DriveGetDrive( "CDROM" )

;if we found 1 or more cdrom drives then check if there's an 
;audio cd in any of them
    If NOT @error Then
        For $i = 1 to $var[0]
        ;change the path ---- used to tell FileFindFirstFile where to search
        ;change it to our cd-rom
            FileChangeDir ( $var[$i]&"\" )
        ; if find a .cda file then means we got an audio cd
            $search = FileFindFirstFile("*.cda")
        ; Check if the search was successful
        ; return appropriate value as specified in func description
            If $search = -1 Then
                Return $FALSE
            Else
            ;return what drive the Audio CD was in
            ;and let user know we found an Audio CD ($TRUE)
                $whatdrive=StringUpper(StringLeft($var[$i],1))
                Return $TRUE
            EndIf
        Next
    Else
        return $FALSE
    EndIf

EndFunc

Share this post


Link to post
Share on other sites

Nice!

The only thing I had to change is to remove "const" from the folllowing code:

Local const $TRUE=1

Local const $FALSE=0

Than it works OK!

Thank you once more!

Share this post


Link to post
Share on other sites

Nice!

The only thing I had to change is to remove "const" from the folllowing code:

Local const $TRUE=1

Local const $FALSE=0

Than it works OK!

Thank you once more!

<{POST_SNAPBACK}>

You're using version 102 then. The Dim CONST function is an addition to the 103 version and works fine with the lates betas.

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites

You're using version 102 then.  The Dim CONST function is an addition to the 103 version and works fine with the lates betas.

<{POST_SNAPBACK}>

OK

Share this post


Link to post
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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...