'Link to the lib: http://www.freebasic.net/forum/viewtopic.php?t=7382 #include "AutoIT3.bi" '+------------------------------------------------------------------------------------------+ '| Header: Check parameters' | '| DisplayCheck:|Il1 are Alt-0124, Big i, small L, one ߎę֚񱸩 | Const Author="CDTray.Bas v0.183b 2007 by ytwinky, MD"' | '| (Shortcut: none) | '| | '| Purpose: Handle your CD-Tray(s).. | '+------------------------------------------------------------------------------------------+ Const Esc=!"\27" Declare Function GetDriveType Alias "GetDriveTypeA" (ByVal nDrive As String) As Integer Declare Function MenuChar(s As String, First As Integer=1, nVG As Integer=8+4) As String Declare Function GetChar(s As String, allowed As String) As String Dim As String actions(1)={"open", "close"}, abbrev="oc" 'action may be o=open or c=close Var c1=lcase(Command(1)), c2=lcase(Command(2)) 'not really necessary, but I'm lazy.. ;-)) Var mc="", drive="", cd="", action AU3_Init AU3_AutoItSetOption("WinTitleMatchMode", -2) For i As Byte=97 to 122 'from 'a' to 'z' If GetDriveType(Chr(i) &":")=5 Then cd+=Chr(i) ' add it if it is a CD/DVD Next 'Now all cd's are in cd(if any..) If cd="" Then 'oops, no cd found.. Print "To use this program you should install at least ONE CD-Drive!" Print "Actually there is none.." GetKey End End If If c1<>"" Then If Instr(cd, Chr(c1[0])) Then drive=Chr(c1[0]) End If If c2<>"" Then If Instr(abbrev, Chr(c2[0])) Then action=Chr(c2[0]) End If If drive="" Then Print Author &!"\nValid drives are:" For i As Byte=1 To Len(cd) Print MenuChar(Chr(cd[i-1])) Next drive=GetChar("Select:", cd &Esc) If drive=Esc Then End End If If action="" Then Print "Valid actions are:" Print MenuChar(actions(0)) Print MenuChar(actions(1)) action=GetChar("Your choice:", abbrev &Esc) If action=Esc Then End End If AU3_CDTray(drive &":", actions(Abs(action="c"))) End Function MenuChar(s As String, First As Integer=1, NewForeground As Integer=8+4) As String Dim As Integer CurrentForeground=LoWord(Color) If First<>1 Then Print Left(s, First-1); Color NewForeground Print Chr(s[First-1]); Color CurrentForeground Return Mid(s, First+1) End Function Function GetChar(s As String, allowed As String) As String Dim As String c If s<>"" Then Print s; Do c=lcase(Input(1)) Loop Until Instr(allowed, c) If Asc(c)>31 Then Print c Return c End Function