SoltrX Posted September 21, 2004 Share Posted September 21, 2004 (edited) Hi, is it possible to check if a cdrom is open or closed ? I want to close the Cd Drive when it's open, but open it when it's closed. DriveStatus ( "path" ) ---------------------------- UNKNOWN Drive may be unformatted (RAW). READY Typical of hard drives and drives that contain removable media. NOTREADY Typical of floppy and CD drives that do not contain media. INVALID May indicate the drive letter does not exist or that a mapped network drive is inaccessible DriveStatus will not work for this, because a cd can be inserted (Status = "READY") or not (Status="NOTREADY"). But when tray is open Status is "NotReady" too. $driveStatus = DriveStatus ("X:") if $driveStatus = "READY" Then CDTray ( "X:","open" ) Else CDTray ( "X:","close" );?????? wrong when no cd is in closed drive EndIf Edit: Code Edited September 21, 2004 by SoltrX Link to comment Share on other sites More sharing options...
Guest BL@(K-R34P3R Posted September 21, 2004 Share Posted September 21, 2004 First, you don't even have those commented out. Put a ";" in front of UNKNOWN, READY, NOTREADY, and INVALID, unless those are some unknown commands Oo. Link to comment Share on other sites More sharing options...
Guest BL@(K-R34P3R Posted September 21, 2004 Share Posted September 21, 2004 Oh wait a minute, I know where you got UNKNOWN and those from. Those are the interpretations in the helpfile. You don't literally put those into the code. Go back and read the readme file again. Link to comment Share on other sites More sharing options...
SoltrX Posted September 21, 2004 Author Share Posted September 21, 2004 sorry my fault... the code box was stupid :"> Link to comment Share on other sites More sharing options...
Guest BL@(K-R34P3R Posted September 21, 2004 Share Posted September 21, 2004 Its ok lol. But I can't help you any further. I'm not that experienced, as far as I'm concerned, you are a much better scripter then me already. Link to comment Share on other sites More sharing options...
emmanuel Posted September 21, 2004 Share Posted September 21, 2004 Hi, is it possible to check if a cdrom is open or closed ? I want to close the Cd Drive when it's open, but open it when it's closed. DriveStatus ( "path" ) ---------------------------- UNKNOWN Drive may be unformatted (RAW). READY Typical of hard drives and drives that contain removable media. NOTREADY Typical of floppy and CD drives that do not contain media. INVALID May indicate the drive letter does not exist or that a mapped network drive is inaccessible DriveStatus will not work for this, because a cd can be inserted (Status = "READY") or not (Status="NOTREADY"). But when tray is open Status is "NotReady" too. $driveStatus = DriveStatus ("X:") if $driveStatus = "READY" Then CDTray ( "X:","open" ) Else CDTray ( "X:","close" );?????? wrong when no cd is in closed drive EndIf Edit: Code <{POST_SNAPBACK}>I'd say first send the command to open it, then have them do what you want them to do, then send the close? I'm assuming that sending an extra Open command to an already open drive won't hurt it? Never have played with it myself, but a quick glance at the helpfile doesn't show any way of finding out if the tray is open or not. I know it's not what you're looking for, but I just wrote this which'll open any cd drives that're empty: $d = DriveGetDrive("CDROM") For $x = 1 to $d[0] if DriveStatus($d[$x]) = "NOTREADY" then CDTray($d[$x],"open") EndIf Next "I'm not even supposed to be here today!" -Dante (Hicks) Link to comment Share on other sites More sharing options...
CyberSlug Posted September 21, 2004 Share Posted September 21, 2004 (edited) Just throwing out some ideas here:1) http://www.ardamax.com/help/open_cdrom.html2) What are the possible states for a drive?A. Tray is open (too bad we can't tell if contains a CD or not )B. Tray is closed and emptyC. Tray (is closed) and CD has not spun up yetD. Tray is closed and CD has spun up (is ready)E. Any others I missed? (anyone know what happens if you call drive status while burning a disc?)We can determine D with DriveStatus("X:") == "READY"To differentiate among A, B, and C, we need ???3) ; get status of drive ; call CDTray("X:", "close") ; if Tray was open, then the status is toggled and we are done ; if tray was closed, then this operation has no effect so we wait a few seconds, check the status again, and compare to the originalAttempt at an implementation for #2 that didn't really go anywhere... On Windows XP, though, it waits for a newly inserted CD to spin up before reporting the drive status....$drive = "G:"; adjust to your CD Drive letter $popupTitle = "cmd.exe"; adjust for different versions of Windows.... $ready = 1; 0=open, 1 = closed AdLibEnable("WatchForDriveNotReadyPopup", 10) Func WatchForDriveNotReadyPopup() If WinActive($popupTitle,"") Then Send("{Esc}") $ready = 0 EndIf EndFunc $drive = "G:"; adjust to your CD Drive letter RunWait(@Comspec & " /c " & $drive & " > nul", "", @SW_HIDE) MsgBox(4096,"Ready?", $ready) Edited September 21, 2004 by CyberSlug Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now