Last active
December 30, 2015 08:49
-
-
Save imryan/7805040 to your computer and use it in GitHub Desktop.
Opens and closes disk tray infinitely.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ctypes | |
def eject(): | |
opens = 0 | |
closes = 0 | |
while (True): | |
# Open disk tray | |
ctypes.windll.WINMM.mciSendStringW(u"open D: type cdaudio alias d_drive", None, 0, None) | |
ctypes.windll.WINMM.mciSendStringW(u"set d_drive door open", None, 0, None) | |
opens += 1 | |
if (opens is 1): | |
print "OPENED:", opens, "TIME" | |
print '\a' | |
else: | |
print "OPENED:", opens, "TIMES" | |
print '\a' | |
# Close disk tray | |
ctypes.windll.WINMM.mciSendStringW(u"set d_drive door closed", None, 0, None) | |
closes += 1 | |
if (closes is 1): | |
print "CLOSED:", closes, "TIME" | |
print '\a' | |
else: | |
print "CLOSED:", closes, "TIMES" | |
print '\a' | |
name = raw_input() | |
eject() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment