我觉得问题不是出在光驱上!看下面的代码
$var =DriveGetDrive ( "CDROM" )
$dapa=$var[1]
Opt("TrayMenuMode", 1)
Opt("trayOnEventMode", 1)
$nb2 = TrayCreateItem("打开光驱 Alt+O")
TrayItemSetOnEvent($nb2, "open")
$xiton=RegRead('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion',"ProductName")
$objWMIService = ObjGet("winmgmts:\\.\root\CIMV2:Win32_SystemEnclosure")
$colItems = $objWMIService.instances_
For $colItem In $colItems
$Types = $colItem.ChassisTypes(0)
Next
if $Types=3 then
$nb3 = TrayCreateItem("关闭光驱 Alt+C")
TrayItemSetOnEvent($nb2, "close")
endif
TrayCreateItem("")
$nb4= TrayCreateItem("退出程序 Alt+Q")
TrayItemSetOnEvent($nb4, "_Exit")
HotKeySet("!q", "_Exit")
HotKeySet("!o", "open")
HotKeySet("!c", "close")
while 1
sleep(1000)
wend
Func open()
CDTray ($dapa, "open" )
EndFunc
Func _Exit()
Exit
EndFunc
Func close()
CDTray ($dapa, "close" )
EndFunc
在我的机器运行这段代码后,如果用托盘的菜单的“打开光驱”,光盘的指示灯只是亮了几下,很多时候光驱都龟缩在里面,只有少数几次可以打开,但如果用热键的话,光驱百分百乘乘地出来!问题何在??? |