' "T610 as a webcam". Copyright (c) 2004 HRS.' this script remotely triggers the camera of the T610,
' transfers the taken picture on the local pc and
' deletes it from the camera.' path and filename of the picture on the camera
Const filename = "/Pictures/Picture(1).jpg"' output directory for the transferred files on the local pc
' terminating backslash required
Const outputdirectory = "c:\Webcam\"Sub OnInit
fma.Debug "OnInit Called"
fma.AddCmd "Take a picture", "OnTakeSinglePicture"
fma.AddCmd "Start Webcam (loop)", "OnStartWebcam"End SubSub OnTakeSinglePicture
Dim cmd
If fma.Connected = 1 Then
  TakePicturee
  MsgBox "Picture taken and sent"
Else
  MsgBox "Not Connected to Phone"
End If
End Sub' ...........................................Sub TakePicturee
Dim cmd
If fma.Connected = 1 Then  cmd = "at+clck=""CS"",0" ' Unlock phone
  Transmit cmd
  
  cmd = "AT+CKPD="":C""" ' Enter camera mode
  Transmit cmd
  
  cmd = "AT+CKPD="":C""" ' Take picture
  Transmit cmd  ' create filename here to get the (more or less) exact time & date of the picture
  outputfile = outputdirectory & LeadZero(Minute (time)) & "-" & LeadZero(Second (time)) & ".jpg"  delay (1)
  cmd = "AT+CKPD="":C""" ' Save picture
  Transmit cmd
  delay (4)
  cmd = "AT+CKPD="":R""" ' Return to main menu
  Transmit cmd  fma.ObexGet outputfile, filename
  fma.ObexDelete filename  
  cmd = "AT+CKPD="":R""" ' Return to main menu
  Transmit cmdEnd If
End Sub
' ...........................................Sub OnStartWebcam
Dim cmdcmd = "at+clck=""CS"",0" ' Unlock phone
 Transmit cmd cmd = "AT+CKPD="":C""" ' Enter camera mode
 Transmit cmdIf fma.Connected = 1 Then
  
  While (true)
      TakePicture
  Wend
Else
  MsgBox "Not Connected to Phone"
End If
End Sub
Sub TakePicture
Dim cmd
 
 If fma.Connected = 1 Then  cmd = "AT+CKPD="":C""" ' Take picture
  Transmit cmd  ' create filename here to get the (more or less) exact time & date of the picture
  outputfile = outputdirectory & LeadZero(Minute (time)) & "-" & LeadZero(Second (time)) & ".jpg"  delay (1)
  cmd = "AT+CKPD="":C""" ' Save picture
  Transmit cmd
  delay (5)
  cmd = "AT+CKPD="":R""" ' Return to main menu
  Transmit cmd
  delay (2)  .... (isn't nessessery)
  fma.ObexGet outputfile, filename
  fma.ObexDelete filenameEnd If
End Sub
Function delay(N)   ' delay N seconds
Dim StartTime, EndTime
StartTime = Timer
EndTime = Timer + N
Do
Loop while EndTime > Timer
End FunctionFunction LeadZero(ByVal N)
 if (N>=0) and (N<10) then LeadZero = "0" & N else LeadZero = "" & N
End Function' FMA enchancements - DO NOT REMOVE/ALTER THIS FUNCTION!!!
Sub FmaInternalObjectCall(command)
 Execute(command)
End Sub' FMA enchancements - DO NOT REMOVE/ALTER THIS FUNCTION!!!
Sub FmaInternalObjectCallEx(command, arguments)
 Dim args, param
 If IsArray(arguments) And UBound(arguments) > -1 Then
     ' Generate argument list
     args = " "
     For Each param In arguments
             args = args & """" & param & """" & ", "
     Next
     ' Cut tailing ","
     If Right(args, 2) = ", " Then args = Left(args, Len(args) -2)
 Else
     args = ""
 End If
 Execute(command & args)
End Sub

解决方案 »

  1.   

    这个程序需要用到额外的库包,Delphi不一定能找到。
    你去找FMA Project,关于T610/618手机的Delphi项目。
      

  2.   

    Const outputdirectory: string = 'c:\Webcam\';procedure OnInit;
    begin
    fma.Debug('OnInit Called'); //这里不明白,要看看fma.Debug的声明
    fma.AddCmd('Take a picture', 'OnTakeSinglePicture');
    fma.AddCmd('Start Webcam (loop)', 'OnStartWebcam');
    End;procedure OnTakeSinglePicture;
    var
      cmd: string;
    begin
    If fma.Connected = 1 Then
    begin
      TakePicturee;
      showmessage('Picture taken and sent');
    end
    Else
      showmessage('Not Connected to Phone');
    End;' ...........................................procedure TakePicturee;
    var
      cmd: string;
    begin
    If fma.Connected = 1 Then
    begin  cmd := 'at+clck=''CS'',0'; // Unlock phone
      Transmit(cmd); //这个不知道,估计是这样的
      
      cmd := 'AT+CKPD='':C'''; // Enter camera mode
      Transmit(cmd);
      
      cmd := 'AT+CKPD='':C'''; //Take picture
      Transmit(cmd);  // create filename here to get the (more or less) exact time + date of the picture
      outputfile = outputdirectory + LeadZero(Minute (time)) + '-' + LeadZero(Second (time)) + '.jpg';  sleep (1000);
      cmd := 'AT+CKPD='':C''' ' Save picture
      Transmit(cmd);
      sleep (4000);
      cmd := 'AT+CKPD='':R'''; // Return to main menu
      Transmit(cmd);  fma.ObexGet(outputfile, filename);
      fma.ObexDelete(filename);  
      cmd := 'AT+CKPD='':R'''; // Return to main menu
      Transmit(cmd);End;//if 
    End;
    ' ...........................................procedure OnStartWebcam;
    var
     cmd: string;
    begin
    cmd := 'at+clck=''CS'',0'; // Unlock phone
     Transmit(cmd); cmd := 'AT+CKPD='':C'''; //  Enter camera mode
     Transmit(cmd);If fma.Connected = 1 Then
    begin
      While (true)//不知道
          TakePicture
      Wend
    end
    Else
      showmessage('Not Connected to Phone');End;
    procedure TakePicture;
    var
     cmd: string
    begin
     
     If fma.Connected = 1 Then
      begin
      cmd := 'AT+CKPD='':C'''; // Take picture
      Transmit(cmd);  // create filename here to get the (more or less) exact time + date of the picture
      outputfile := outputdirectory + LeadZero(Minute (time)) + '-' + LeadZero(Second (time)) + '.jpg';  sleep (1000);
      cmd := 'AT+CKPD='':C'''; // Save picture
      Transmit(cmd);
      sleep (5000);
      cmd := 'AT+CKPD='':R''' //Return to main menu
      Transmit(cmd);
      sleep (2000);  .... (isn't nessessery)
      fma.ObexGet( outputfile, filename);
      fma.ObexDelete( filename);End;// If
    End;Function LeadZero(var N:integer):string;
     if (N>=0) and (N<10) then 
       result := '0' + inttostr(N) 
     else 
       result := '' + inttostr(N);
    End;' FMA enchancements - DO NOT REMOVE/ALTER THIS FUNCTION!!!
    procedure FmaInternalObjectCall(command: string);
    begin
     Execute(command);
    End;' FMA enchancements - DO NOT REMOVE/ALTER THIS FUNCTION!!!
    procedure FmaInternalObjectCallEx(command: string; arguments//不知道什么类型);
    var
      args: string;
      param: integer;
    begin
     If IsArray(arguments) And (UBound(arguments) > -1) Then
     begin
         // Generate argument list
         args := ' ';
         //下面这段不知道
         For Each param In arguments
                 args := args + '''' + param + '''' + ', ';
         
         // Cut tailing ','
         If copy(args, length(args)-1, 2) = ', ' Then args = copy(args, 1, Length(args) -2);
     end
     Else
         args = '';
     Execute(command + args);
    End;
      

  3.   

    zzlingaaa(小舟)兄,你太棒了,谢谢你:)