'Quelle fr die Lib: http://www.freebasic.net/forum/viewtopic.php?t=7382 #include once "windows.bi" #include once "AutoIT3y.bi" '+------------------------------------------------------------------------------------------+ '| Header: Evalute the parameters | '| DisplayCheck:|Il1 are Alt-0124, big i, small L, One ᎙=ܱ | Const Author="FBCDTray.Bas v1.017 2007 by ytwinky, MD"' | '| (Shortcut: none) | '| tested with FB0.16b, FB0.17f, FBCVS | '| Purpose: manage the cd-tray of your optical drives.. | '+------------------------------------------------------------------------------------------+ Declare Function GetOptDrives() As String 'Okay.. Const BS=!"\8", Lf=!"\10", Cr=!"\13", CrLf=Cr &Lf, Esc=!"\27", light=8, red=4, yellow=6, actions="OC" Dim As Integer i, Okay, zeile, spalte Dim As String mc, OptDrives=GetOptDrives(), cd=Left(UCase(Command(1)), 1), action=UCase(Command(2)) Function GetChar(byVal s As String, byVal Allowed As String, byVal UpCase As Integer=0) As String 'returns a single char Dim mc As String 'it is always a good habit to declare variables, we are going to use.. If s<>"" Then Print s; 'show inputprompt, if any.. Do mc=InKey Sleep(1) If UpCase Then mc=UCase(mc) 'convert if desired Loop Until InStr(Allowed, mc) 'mc is allowed.. Function=mc End Function ' done.. Function MenuChar(s As String, First As Integer=1, nFG As Integer=light+red) As String 'Okay, as always :D Dim As Integer cFG=LoWord(Color) 'remember current foreground colour If First<>1 Then Print Left(s, First-1); 'print the string before selected char, Left() !Mid() Color nFG 'change colour to new foreground colour Print Chr(s[First-1]); 'print selected char Color cFG 'change colour to previous one Function=Mid(s, First+1) 'return the remaining string.. End Function 'guess what.. :D Function GetOptDrives() As String 'Okay.. Dim As String Drives, Drive, mc Dim As Integer Result, i Dim Buffer As String*255 Result=GetLogicalDriveStrings(Len(Buffer), Buffer) Drives=Left(Buffer, Result) For i=1 To Len(Drives) Step 4 Drive=Mid(Drives, i, 3) If GetDriveType(Drive)=5 Then mc+=Left(Drive, 1) Next Function=mc End Function Sub DoItOrNot(byVal cd As String, byVal action As String, byVal OptDrives As String, byVal StopNow As String="") Dim Lw As String=cd 'yes, I'm a coward: better use a copy of a 'copy' If Right(cd, 1)<>":" Then Lw+=":" If (InStr(OptDrives, cd)<>0 And InStr(actions, action)<>0) Then AU3_CDTray(Lw, *IIF(InStr(actions, action)=1, @"open", @"close")) If StopNow<>"" Then End End If End Sub If Len(OptDrives)=0 Then 'without CD/DVD there is no tray.. Print "No optical drive found, you should install one.. :D" GetKey End End If DoItOrNot(cd, action, OptDrives, "and finish") 'so it should work with a commandline.. Cls Do Locate 1, 1 Print Author If cd<>"" And Instr(OptDrives, cd)=0 Then Print cd &" is not an optical drive.." If Len(OptDrives)>1 Then Print "Select an optical drive:" For i=1 To Len(OptDrives) Print MenuChar(Chr(OptDrives[i-1]), 1, light+IIF(cd=Chr(OptDrives[i-1]), yellow, red)) Next Else cd=OptDrives &":" Print "Available optical drive is " &cd End If Print "Select an action:" Print MenuChar("Open", 1, light+IIF(action="O", yellow, red)) Print MenuChar("Close", 1, light+IIF(action="C", yellow, red)) DoItOrNot(cd, action, OptDrives) mc=GetChar("..and now? " & BS, OptDrives &actions &Esc, 1) If mc=Esc Then End If InStr(actions, mc) Then action=mc If InStr(OptDrives, mc) Then cd=mc Loop Until mc=Esc End