RazerM Posted April 22, 2006 Posted April 22, 2006 How can i find out if the cd tray is open(except from looking ) My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
GrungeRocker Posted April 22, 2006 Posted April 22, 2006 How can i find out if the cd tray is open(except from looking );=============================================================================== ; Description: Open, Close, and Toggle CD Door ; Usage _OpenCDDoor(DriveName) ; _CloseCDDoor(DriveName) ; _ToggleCDDoor(DriveName) ; Author(s): Ward ;=============================================================================== Func _MCISendString($Str) DllCall("winmm.dll", "int", "mciSendString", "str", $str, "int", 0, "int", 0, "int", 0) EndFunc Func _OpenCDDoor($Drive) _MCISendString("Open " & $Drive & " Alias Drive" & $Drive & " Type CDAudio") _MCISendString("Set Drive" & $Drive & " Door Open") EndFunc Func _CloseCDDoor($Drive) _MCISendString("Open " & $Drive & " Alias Drive" & $Drive & " Type CDAudio") _MCISendString("Set Drive" & $Drive & " Door Closed") EndFunc Func _ToggleCDDoor($Drive) _MCISendString("Open " & $Drive & " Alias Drive" & $Drive & " Type CDAudio") $Timer = TimerInit() _MCISendString("Set Drive" & $Drive & " Door Open") If TimerDiff($Timer) < 200 Then _MCISendString("Set Drive" & $Drive & " Door Closed") EndIf EndFunc [font="Verdana"]In work:[list=1][*]InstallIt[*]New version of SpaceWar[/list] [/font]
elgabionline Posted April 22, 2006 Posted April 22, 2006 (edited) How can i find out if the cd tray is open(except from looking ) mmm GrungeRocker, that not. He need read status, not open or close cd tray.. RazerM, maybe this help: $dll = DllOpen("winmm.dll") $CD= DllCall($dll, "int", "mciSendString", "str", "status cdaudio mode", "str", "str", "int", 255, "long", 0) $statusCD=$CD[2] [EDIT] Oops, I forget put the open dll... Edited April 22, 2006 by elgabionline
RazerM Posted April 22, 2006 Author Posted April 22, 2006 thanks elgabionline but it still says open even if drive is closed My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
GrungeRocker Posted April 22, 2006 Posted April 22, 2006 razer think of that ive posted... that checks if cdtray is opened, to close it then [font="Verdana"]In work:[list=1][*]InstallIt[*]New version of SpaceWar[/list] [/font]
bhoar Posted June 26, 2006 Posted June 26, 2006 (edited) This one is going to require the use of the SCSI Passthrough interface. As far as I can tell, windows does not directly expose via the windows API the inquiry response bit that indicates the tray position. This is presumably because it wasn't part of the original ATAPI/SCSI standards and they like to keep their low-level stuff at the lowest-common-denominator level. I currently use a batch file wrapped around plscsi as a script to get the tray status by sending a 0xBD CDB directly to the drive and semi-parsing the results. If not exist %1 goto setdrive goto setdefault :setdrive set PLSCSI=\\.\%1 goto scsicommand :setdefault set PLSCSI=\\.\D: :scsicommand plscsi.exe -v -x "BD 00 00 00 00 00 00 00 00 08 00 00" -i x8 And then scan the second line of output result for "x 00000000 00:10:00:00" where that "1" represents the tray being open. Note that this is very sloppy, in that there are situations where other bits may be set on the results and I don't check for errors. Anyone with any experience using IOTCL_SCSI_PASS_THROUGH or IOTCL_SCSI_PASS_THROUGH_DIRECT from AutoIT who'd like to take a crack at this? If I can get one example working, there are several other fun things that can be done (e.g. a more complicated series of inquiries can be used to figure out the *type* of media inserted {CD,DVD}{-ROM,-R,-RW} etc.). -brendan Edited June 26, 2006 by bhoar
bhoar Posted June 28, 2006 Posted June 28, 2006 Ok, I've put together some sample code that seems to do everything right, but nothing happens. Anyone interested in code that asks the drive itself what the current tray position is via the IOCTL_SCSI_PASS_THROUGH mechanism? If so, I'll post it when I get my SCITE environment fixed (I installed the newest version and now it consumes 99% of CPU when I start it and hangs) and cut out all of the crud so that it at least appears to be respectable code. -brendan
bhoar Posted June 28, 2006 Posted June 28, 2006 Ok, I continued this in a new thread:http://www.autoitscript.com/forum/index.php?showtopic=28326-brendan
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