#include "C:\AutoIt\autoit-v3\com\include\default.au3" $status = "open" $hotkey = 0 $drives = DriveGetDrive ( "CDROM" ) AutoItSetOption("TrayMenuMode", 1) $menu_drives = TrayCreateMenu ( "Laufwerk(e)" ) Global $drive[$drives[0] + 1] $drive[0] = $drives[0] For $i = 1 to $drive[0] $drive[$i] = TrayCreateItem($drives[$i], $menu_drives, $i - 1, 1) Next TrayItemSetState ( $drive[1], $TRAY_CHECKED ) $menu_open = TrayCreateItem ( "öffnen" ) TrayCreateItem ( "" ) $menu_hotkey = TrayCreateItem ("Hotkey aktivieren") TrayCreateItem ( "" ) $menu_exit = TrayCreateItem ( "beenden" ) While 1 $TrayMsg = TrayGetMsg() If $TrayMsg = $menu_exit Then Exit If $TrayMsg = $menu_open Then CDOpenClose() If $TrayMsg = $TRAY_EVENT_PRIMARYDOUBLE Then CDOpenClose() If $TrayMsg = $menu_hotkey Then HotkeyToggle() Sleep(5) WEnd Func HotkeyToggle() If $hotkey = 0 Then HotKeySet("{NUMPADSUB}", "CDOpenClose") $hotkey = 1 TrayItemSetText($menu_hotkey, "Hotkey deaktivieren") Else HotKeySet("{NUMPADSUB}") $hotkey = 0 TrayItemSetText($menu_hotkey, "Hotkey aktivieren") EndIf EndFunc Func CDOpenClose() For $i = 1 to $drive[0] ;_Debug(TrayItemGetState($drive[$i])) If (TrayItemGetState($drive[$i]) = 65) Then $CDROM = TrayItemGetText($drive[$i]) ;_Debug("Got_CDROM") EndIf Next ;_Debug($CDROM) If CDTray ( $CDROM, $status ) Then Select Case $status = "open" $status = "closed" TrayItemSetText($menu_open, "schliessen") Case $status = "closed" $status = "open" TrayItemSetText($menu_open, "öffnen") EndSelect EndIf ;_Debug($status) EndFunc