Hi everyone, I'm doing some experiences with python in Windows Vista and I was wondering to know how to eject the tray of CDs.
Well, I'm not Dan, but here's a little hack adapted from http://www.dotnetspider.com/resources/15834-eject-close-cd-tray.aspx for Python. It's only two lines of code!
import ctypes ctypes.windll.winmm.mciSendStringW("set cdaudio door open", None, 0, None)
import ctypes ctypes.windll.winmm.mciSendStringW("set cdaudio door closed", None, 0, None)
Note, if you're using python 2.x, either change mciSendStringW to mciSendStringA, or change the first argument to a unicode string (recommended) by prefixing it with a lowercase u.
Thanks Scru, it works perfectly.