Nanaki Posted August 2, 2005 Share Posted August 2, 2005 Hi, see topic-name, is it possible? I use DirveStatus to detect if a tray has a disc or not, and CDTray to eject when it doesn't. However, this gives problems when the event occurs and the CDTray is just closing or is already open. So can I detect if a cd-tray is shut, even when no disc is inserted? Tnx in advance, Link to comment Share on other sites More sharing options...
Valuater Posted August 2, 2005 Share Posted August 2, 2005 (edited) Hi,see topic-name, is it possible? I use DirveStatus to detect if a tray has a disc or not, and CDTray to eject when it doesn't. However, this gives problems when the event occurs and the CDTray is just closing or is already open.So can I detect if a cd-tray is shut, even when no disc is inserted?Tnx in advance,<{POST_SNAPBACK}>This should help... used firstCDTray ( "drive", "close" )sleep(5000)?????8) Edited August 2, 2005 by Valuater Link to comment Share on other sites More sharing options...
Nanaki Posted August 2, 2005 Author Share Posted August 2, 2005 Not what I meant. I just want to detect if the tray is closed or not. Link to comment Share on other sites More sharing options...
scriptkitty Posted August 2, 2005 Share Posted August 2, 2005 (edited) Got me on that one. The drive close script adds time, and with folks at my work, they might have left thier coffee in the cupholder there. I think there is a drive status DLL call if nothing else, I will take a look if no one finds it first.You are saying the built in version of drivestatus doesn't meet your needs, correct?DriveStatus --------------------------------------------------------------------------------Returns the status of the drive as a string.DriveStatus ( "path" )Parameterspath Path of drive to receive information from. Return ValueReturn Value Interpretation 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. Edited August 2, 2005 by scriptkitty AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
Truffle Posted August 2, 2005 Share Posted August 2, 2005 No easy way that I can tell. The logical way (atleast to me) is to send an open command. and if open = false then it must mean thats its already open.. I tried that though and it didnt work. Link to comment Share on other sites More sharing options...
Nanaki Posted August 3, 2005 Author Share Posted August 3, 2005 Thanks for the help, all.You are saying the built in version of drivestatus doesn't meet your needs, correct?<{POST_SNAPBACK}>Correct. Link to comment Share on other sites More sharing options...
scriptkitty Posted August 3, 2005 Share Posted August 3, 2005 I looked around, couldn't find one for ya. I usually just check ready status, and then check for filenames on the disk, etc. Sorry I couldn't be more help this time. AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
Nanaki Posted August 3, 2005 Author Share Posted August 3, 2005 Crap. Thanks anyway. So there's absolutely no way to check this? Link to comment Share on other sites More sharing options...
hgeras Posted August 4, 2005 Share Posted August 4, 2005 (edited) Actually I found nothing too in msdn and it seems that not even windows can support that.... But I came up with that code.It might be useful..... $timer=TimerInit() while TimerDiff($Timer)<150 CDTray("F:","CLOSE") WEnd if DriveStatus("F:")="NOTREADY" Then msgbox(0,"","Cd is now closed and with no CD inserted") Else msgbox(0,"","Cd is now closed and with CD inserted") EndIf I timed my cdrom and saw that if the cdtray is already closed the CDTray("F:","CLOSE") close command needs around 100ms to execute.... if it is in another state then it needs above 6500ms...So if the drive is already closed the it will notify right away that it is closed,otherwise it will remain in the loop until it is closed even if no media is inserted.... I'm sorry but i couldnt come up with something better..... Edited August 4, 2005 by hgeras Useful information about COM/Objects referenceMy Scripts:PapDefragNvidia Temperature Logger V3.0 with graph analyzerAutoiIt Update Checker And Downloader V1.0ArrayPush UDF Link to comment Share on other sites More sharing options...
scriptkitty Posted August 4, 2005 Share Posted August 4, 2005 (edited) So there's absolutely no way to check this?I wouldn't say that, I just couldn't find a program, dll, or any windows call or signal myself.The closest ones are basically the same as posted, check drive, send a close signal, and check again.edit.. thought about posting a few other scripts in vb, dll calls, and some hardware checks, but they all did the same thing hgeras' code did pretty much, so I removed it. Edited August 4, 2005 by scriptkitty AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
LxP Posted August 4, 2005 Share Posted August 4, 2005 (edited) So there's absolutely no way to check this?<{POST_SNAPBACK}>I'm pretty certain that you can check for this using MCI, but I believe that you are limited to checking only the first CD drive in the system and I'm not aware of any way to make MCI calls and receive their results with AutoIt.Edit: my old MCI documentation confirms that this is indeed possible. Edited August 4, 2005 by LxP Link to comment Share on other sites More sharing options...
Nanaki Posted August 4, 2005 Author Share Posted August 4, 2005 Thanks all again. @hgeras: thought about that, but I want to use this on both a laptop and desktop. On a laptop you can't close the drive. Also, the time differs from drive to drive. @scriptkitty: ditto @LxP: the latest bèta of AutoIT is able to process MCI-commands, so could you post that documentation please? Link to comment Share on other sites More sharing options...
LxP Posted August 4, 2005 Share Posted August 4, 2005 Could you please tell me more about that? I couldn't find any mention of MCI in the help file and I'm running the latest beta at this time.MCI.zip Link to comment Share on other sites More sharing options...
hgeras Posted August 4, 2005 Share Posted August 4, 2005 (edited) Nanaki: The While statement doesnt have to do with the cdrom time but how long it takes autoit to process the command .In my computer(A64 3000+) needs 95-105 ms. In a slower a computer might need a little longer thats why i used 150 ms .... In a laptop tends to return 0 but thats not much of a problem since you can alter\enrich the code for that case too and make it wait for someone to close it with timeout function too (e.g 5sex err...secs I meant )or you might add it as an option e.g (checkbox)Laptop computer? , and alter tge code accordingly for that case....That's all from my point of view given the fact that if MCI documentation is inadequate then the use of its code would be hell.... LxP: I'd like that code posted too....(You did that just before posting ....) EDIT: I checked the documentation and i couldnt find anything useful for your case Nanaki... BTW where is the MCI processing documentation in autoit? Edited August 4, 2005 by hgeras Useful information about COM/Objects referenceMy Scripts:PapDefragNvidia Temperature Logger V3.0 with graph analyzerAutoiIt Update Checker And Downloader V1.0ArrayPush UDF Link to comment Share on other sites More sharing options...
LxP Posted August 4, 2005 Share Posted August 4, 2005 (edited) Just for the record, I think you'll want a command like status cdaudio mode which will potentially return open or other things. See Contents > Audio CD Commands > status for more info.Edit: this message is in relation to MCI commands and refers to the help file posted above. Edited August 4, 2005 by LxP Link to comment Share on other sites More sharing options...
Nanaki Posted August 4, 2005 Author Share Posted August 4, 2005 (edited) Indeed, the documentation states it can report "open".http://www.autoitscript.com/forum/index.php?showtopic=10534Here's some mention of MCI, I'll try asking in another forum.edit= another one: http://www.autoitscript.com/forum/index.ph...wtopic=8760&hl=Looks like mciSendString("status cdaudio mode") should do it. Now I don't really know how to edit "device_id" to work on multiple drives, so I'm looking into that. edit2= does anyone know how to specify your own drive? Edited August 4, 2005 by Nanaki 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