Is it possible to open/close the CD tray from a macro? I looked around and couldn't find it - thought I'd ask just in case I missed something.
Thanks!
Open/Close CD Tray?
Moderators: Dorian (MJT support), JRL
I didn't find a way to close but this I found this vbscript that can open my cd tray. This could most likely be cleaned up and made to run through Macro Scheduler by someone good with VBScripting.
Code: Select all
Let>file1=%temp_dir%cdeject.vbs
IfFileExists>File1
DeleteFile>file1
EndIf
WriteLn>file1,wres,Set oWMP = CreateObject("WMPlayer.OCX.7" )
WriteLn>file1,wres,Set colCDROMs = oWMP.cdromCollection
WriteLn>file1,wres,
WriteLn>file1,wres,if colCDROMs.Count >= 1 then
WriteLn>file1,wres, For i = 0 to colCDROMs.Count - 1
WriteLn>file1,wres, colCDROMs.Item(i).Eject
WriteLn>file1,wres, Next ' cdrom
WriteLn>file1,wres,End If
Wait>0.5
Let>rp_wait=1
Let>rp_windowmode=0
Run>cmd /c %file1%
DeleteFile>file1
Last edited by JRL on Fri Nov 14, 2008 5:33 am, edited 1 time in total.
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Here you go:JRL wrote:I didn't find a way to close but this I found this vbscript that can open my cd tray. This could most likely be cleaned up and made to run through Macro Scheduler by someone good with VBScripting.
Code: Select all
Let>file1=%temp_dir%cdeject.vbs IfFileExists>File1 DeleteFile>file1 EndIf WriteLn>file1,wres,Set oWMP = CreateObject("WMPlayer.OCX.7" ) WriteLn>file1,wres,Set colCDROMs = oWMP.cdromCollection WriteLn>file1,wres, WriteLn>file1,wres,if colCDROMs.Count >= 1 then WriteLn>file1,wres, For i = 0 to colCDROMs.Count - 1 WriteLn>file1,wres, colCDROMs.Item(i).Eject WriteLn>file1,wres, Next ' cdrom WriteLn>file1,wres,End If Wait>0.5 Let>rp_wait=1 Let>rp_windowmode=0 Run>cmd /c %file1% DeleteFile>file1
Code: Select all
VBSTART
Sub EjectTray
Set oWMP = CreateObject("WMPlayer.OCX.7")
Set colCDROMs = oWMP.cdromCollection
If colCDROMs.Count >= 1 Then
For i = 0 to colCDROMs.Count - 1
colCDROMs.Item(i).Eject
Next ' cdrom
End If
End Sub
VBEND
VBRun>EjectTray
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
As to your first question of open and close
add another - colCDROMs.Item(i).Eject
if you want to loop, use the do and loop at beginning and end
if you have two cd roms and just want the second one to open
use: For i = 1 to colCDROMs.Count - 1
instead of: For i = 0 to colCDROMs.Count - 1
VBSTART
Sub EjectTray
Set oWMP = CreateObject("WMPlayer.OCX.7")
Set colCDROMs = oWMP.cdromCollection
If colCDROMs.Count >= 1 Then
For i = 0 to colCDROMs.Count - 1
colCDROMs.Item(i).Eject
colCDROMs.Item(i).Eject
Next ' cdrom
End If
End Sub
VBEND
VBRun>EjectTray
add another - colCDROMs.Item(i).Eject
if you want to loop, use the do and loop at beginning and end
if you have two cd roms and just want the second one to open
use: For i = 1 to colCDROMs.Count - 1
instead of: For i = 0 to colCDROMs.Count - 1
VBSTART
Sub EjectTray
Set oWMP = CreateObject("WMPlayer.OCX.7")
Set colCDROMs = oWMP.cdromCollection
If colCDROMs.Count >= 1 Then
For i = 0 to colCDROMs.Count - 1
colCDROMs.Item(i).Eject
colCDROMs.Item(i).Eject
Next ' cdrom
End If
End Sub
VBEND
VBRun>EjectTray
Aaron