Opens or closes the CD tray.
CDTray ( "drive", "status" )
drive | The drive letter of the CD tray to control, in the format D:, E:, etc. |
status | Specifies if you want the CD tray to be open or closed: $CDTRAY_OPEN ("open") - to be open $CDTRAY_CLOSED ("closed") - to be closed on cd tray (not laptop-style) Constants are defined in AutoItConstants.au3 |
Success: | 1. |
Failure: | 0 if drive is locked via CD burning software or if the drive letter is not a CD drive. |
CDTray() works as expected with virtual CD drives such as DAEMON Tools.
CDTray() does not work on non-local/mapped CD drives; CDTray() must be run from the computer whose drive it affects.
CDTray("X:", "close") returns 1 on laptop-style cd trays that can only be closed manually.
#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>
; Get List of all CDRom's
Local $aCDRom = DriveGetDrive($DT_CDROM)
If @error Then
MsgBox($MB_SYSTEMMODAL, "", "No CDRom found.")
Exit
EndIf
; Open the CD tray of the first CDRom
CDTray($aCDRom[1], $CDTRAY_OPEN)
Sleep(2000)
CDTray($aCDRom[1], $CDTRAY_CLOSED) ; does not work on laptop-style cd trays that can only be closed manually.