Jump to content

Skype4COM recording functions


DK12000
 Share

Recommended Posts

I think I posted my original question in the wrong forum. Can a mod please

The Skype4COM.dll wrapper has the ability to record the incoming and mic audio on an active Skype call. I have successfully used Airwolf's excellent but can not get the syntax right for the call recording.

I have tried many variations of the below :

$aCall.CaptureMicDevice($oSkype.TCallIoDeviceType.callIoDeviceTypeFile,"C:\test123.wav") ; Record Mic input

$aCall.OutputpDevice($oSkype.CallIoDeviceType.callIoDeviceTypeFile)="C:\test1234.wav" ; Record incoming audio

To aid in testing I have created this script. The script attaches to Skype and Skype will prompt to allow permission. Once running it sits in the tray waiting for the call status to change. When an incoming call is received a msgbox will prompt the incoming call. Answer the call first then click the msgbox, it will go to in-progress and should start the recording. I keep getting "Invalid number of parameters" or "Type mismatch" errors from the COM error handler.

I've included several pieces of code that I've found in my research that work for C# and VB. I just cant translate them to AutoIt apparently.

Any help greatly appreciated.

#include <IE.au3>
#Include <File.au3>
_IEErrorHandlerRegister ("MyErrFunc"); Register a customer error handler

Global $oSkype = "",$988 = 0, $oo = 0, $wew = "", $T3 = "", $tis ="", $00 = 1, $pp = "", $aCall
$logfile = "loghere.txt"
$866 = ""
_SkypeConnect()


Func _SkypeConnect() ; Create a Skype4COM object:
$988 = 1 ; Set COM creation flag
$oSkype = ObjCreate("Skype4COM.Skype")
$oSkypeEvent = ObjEvent($oSkype,"Skype_")
$988 = 0 ; Unset COM creation flag
;// Start the Skype client:
If Not $oSkype.Client.IsRunning Then
    _FileWriteLog ($logfile, "Skype not running, starting skype.")
    $oSkype.Client.Start()
    SLeep ( 3000 )
EndIf
_Auth()
EndFunc


Func _Auth()
    While 1 ; Check for and wait for user to authorize connection to skype API
        $866 = $866 + "1"
        Sleep(1000)
            If $oSkype.CurrentUserStatus = $oSkype.Convert.TextToUserStatus("ONLINE") Then
            ExitLoop
        Else
            $oSkype.ChangeUserStatus($oSkype.Convert.TextToUserStatus("ONLINE"))
        EndIf
        If $866 = 8 then _error("Skype cant go online.")
    WEnd
EndFunc


Func MyErrFunc(); COM error handler
    ; Important: the error object variable MUST be named $oIEErrorHandler
    $ErrorScriptline = $oIEErrorHandler.scriptline
    $ErrorNumber = $oIEErrorHandler.number
    $ErrorNumberHex = Hex($oIEErrorHandler.number, 8)
    $ErrorDescription = StringStripWS($oIEErrorHandler.description, 2)
    $ErrorWinDescription = StringStripWS($oIEErrorHandler.WinDescription, 2)
    $ErrorSource = $oIEErrorHandler.Source
    $ErrorHelpFile = $oIEErrorHandler.HelpFile
    $ErrorHelpContext = $oIEErrorHandler.HelpContext
    $ErrorLastDllError = $oIEErrorHandler.LastDllError
    $ErrorOutput = ""
    $ErrorOutput &= "--> COM Error Encountered in " & @ScriptName & @CRLF
    $ErrorOutput &= "----> $ErrorScriptline = " & $ErrorScriptline & @CRLF
    $ErrorOutput &= "----> $ErrorNumberHex = " & $ErrorNumberHex &  @CRLF
    $ErrorOutput &= "----> $ErrorNumber = " & $ErrorNumber &  @CRLF
    $ErrorOutput &= "----> $ErrorWinDescription = " & $ErrorWinDescription &  @CRLF
    $ErrorOutput &= "----> $ErrorDescription = " & $ErrorDescription &  @CRLF
    $ErrorOutput &= "----> $ErrorSource = " & $ErrorSource &  @CRLF
    $ErrorOutput &= "----> $ErrorHelpFile = " & $ErrorHelpFile &  @CRLF
    $ErrorOutput &= "----> $ErrorHelpContext = " & $ErrorHelpContext &  @CRLF
    $ErrorOutput &= "----> $ErrorLastDllError = " & $ErrorLastDllError
    _FileWriteLog ($logfile, $ErrorOutput)
    If $988 = 1 then
        _error("Could not create Skype Object, please ensure Skype4COM.dll is on your system and registered."&@LF&"You may need to re-install skype with the Extras Manager enabled")
    Else
        If $ErrorDescription = "Wait timeout." then ; Check to see if Skype is asking for connection authorization
                If WinExists ("[TITLE:Skype™ - Useful tip; CLASS:TCommunicatorForm.UnicodeClass]") Then
                    WinActivate("[TITLE:Skype™ - Useful tip; CLASS:TCommunicatorForm.UnicodeClass]")
                    TrayTip ("","Please allow Skowler to communicate with Skype",30,2)
                    TraySetToolTip( "Waiting for user action")
                        While WinExists ("[TITLE:Skype™ - Useful tip; CLASS:TCommunicatorForm.UnicodeClass]")
                            Sleep ( 500 )
                        WEnd
                    _Auth()
                Else
                    _error("COM error encountered")
                EndIf
        Else
            _error("COM error encountered")
        EndIf
    EndIf
EndFunc  ;==>MyErrFunc

Func Skype_AttachmentStatus($aStatus); The AttachmentStatus event handler monitors attachment status and automatically attempts to reattach to the API following loss of connection:
    If $aStatus = $oSkype.Convert.TextToAttachmentStatus("AVAILABLE") Then
        $oSkype.Attach()
    EndIf
    If $aStatus = $oSkype.Convert.TextToAttachmentStatus("SUCCESS") Then
        TraySetIcon()
        TrayTip ("","Skowler connected successfully",2)
        TraySetToolTip( "Skowler is connected")
    EndIf
EndFunc

Func _error($prob); Display error msg, logs to file and quits
    TraySetIcon( @ScriptFullPath, -5)
    TrayTip ("","Error",3)
    TraySetToolTip( "Error")
    MsgBox ( 16, "Skowler Error", "Cant continue because : "&$prob)
    _FileWriteLog ($logfile, "Error : Cant continue because : "&$prob)
    If @error then MsgBox ( 16, "Error", "Cant write to logfile, Please check file/folder permissions."); Error box if error on log write
    _IEErrorHandlerDeregister ()
    Exit
EndFunc

;--------Record Skype Call

Func Skype_CallStatus($aCall, $aStatus)
    MsgBox(0,"","Call " & $aCall.Id & " status " & $aStatus & " " & $oSkype.Convert.CallStatusToText($aStatus))
    If $oSkype.Convert.TextToCallStatus("INPROGRESS") Then
        ConsoleWrite($aCall.Id.ToString)
;-------Neither of these work.
        $aCall.CaptureMicDevice($oSkype.TCallIoDeviceType.callIoDeviceTypeFile,"C:\test123.wav") ; Record Mic input
        $aCall.OutputDevice($oSkype.CallIoDeviceType.callIoDeviceTypeFile)="C:\test1234.wav"    ; Record incoming audio

    EndIf
EndFunc

;------------------------

While 1

WEnd


;-------------------Random collection of code to record found on web


;~ CaptureMicDevice(TCallIoDeviceType.callIoDeviceTypeFile, @"C:\Microphone" + call.Id.ToString() + ".wav");

;-----------C# code--------------http://forum.skype.com/index.php?showtopic=109530
;~ var call = skype.PlaceCall("echo123", "", "", "");
;~ call.set_CaptureMicDevice(SKYPE4COMLib.TCallIoDeviceType.callIoDeviceTypeFile, @"c:\Skype1.wav");
;~ call.set_OutputDevice(SKYPE4COMLib.TCallIoDeviceType.callIoDeviceTypeFile, @"c:\Skype2.wav");
;-------------------------

;------------VB 2008 -------------http://forum.skype.com/index.php?showtopic=283791
;~ Public Class Form1
;~  Public WithEvents oSkype As New SKYPE4COMLib.Skype

;~  Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.Load
;~      Try
;~          oSkype = New SKYPE4COMLib.Skype
;~          ' Start Skype if Needed
;~          If oSkype.Client.IsRunning = False Then
;~              oSkype.Client.Start(True)
;~          End If
;~          ' Normal timeout is 30 seconds, lets make it 2 minutes
;~          ' This value is in Milliseconds
;~          oSkype.Timeout = 120000
;~          ' Connect to Skype
;~          oSkype.Attach(8)
;~      Catch ex As Exception
;~          MsgBox("Attach Failed" + ex.ToString, MsgBoxStyle.Information)
;~      End Try
;~  End Sub
;~  Private Sub oSkype_CallStatus(ByVal pCall As SKYPE4COMLib.ICall, ByVal Status As SKYPE4COMLib.TCallStatus) Handles oSkype.CallStatus
;~      If Status = SKYPE4COMLib.TCallStatus.clsInProgress Then
;~          Try
;~              pCall.OutputDevice(SKYPE4COMLib.TCallIoDeviceType.callIoDeviceTypeFile) = "C:\\Output" + pCall.Id.ToString() + ".wav"
;~              pCall.CaptureMicDevice(SKYPE4COMLib.TCallIoDeviceType.callIoDeviceTypeFile) = "C:\\Microphone" + pCall.Id.ToString() + ".wav"
;~          Catch ex As Exception
;~              MsgBox("Record Failed" + ex.ToString, MsgBoxStyle.Information)
;~          End Try
;~      End If
;~  End Sub

;~ End Class
;--------------------------

;--------------------------
;~    try
;~             {
;~                 // Record Calls/Inject Audio Example
;~                 if (status == TCallStatus.clsInProgress)
;~                 {
;~                     // Save your voice to a wav file for the call by Call.Id
;~                     call.set_CaptureMicDevice(TCallIoDeviceType.callIoDeviceTypeFile, @"C:\Microphone" + call.Id.ToString() + ".wav");

;~                     // Save the other persons voice to a wav file for the call by Call.Id
;~                     call.set_OutputDevice(TCallIoDeviceType.callIoDeviceTypeFile, @"C:\Output" + call.Id.ToString() + ".wav");

;~                     // Inject Audio into a call, place ai16.wav in your C:\ directory
;~                     // which is attached as an attachment here, and uncomment this line below.
;~                     //call.set_InputDevice(TCallIoDeviceType.callIoDeviceTypeFile, @"C:\ai16.wav");

;~                 }
;~             }
;~             catch (Exception e)
;~             {
;~                 // Log an error, drop into debug if needed.
;~                 AddTextToTextBox1(DateTime.Now.ToLocalTime() + ": " +
;~                 " Our Code - Unable To record call/inject Audio: " + call.Id.ToString() +
;~                 " - Exception Source: " + e.Source + " - Exception Message: " + e.Message +
;~                 "\r\n");
;--------------------------------
Link to comment
Share on other sites

  • 7 months later...

Hello. Have you ever found a solution to your problem? I am also using the Skype4COMLib and need to record a call. I've seen the code here but I don't have that much experience with C# nor autoit, coming from a web application developing environment. Any help would be appreciated.

Thanks!

Edited by calavera
Link to comment
Share on other sites

  • 2 weeks later...

I know you might have solved the issue, but in case you did not here is the solution for recording streams on SKYPE

func StartMonitor()
ConsoleWrite(@CRLF& "startmonitor" &@CRLF)
if $oSkype.ActiveCalls.count > 0 then
  $CallId = $oSkype.ActiveCalls.Item(1).ID ;1 is the active call
  $CallObj= $oSkype.ActiveCalls.Item(1); this is the general object
  $FileAudio= @DesktopDir & "\Audio.wav"
  $FileMic  = @DesktopDir & "\Mic.wav"
  $oSkype.ActiveCalls.Item(1).OutputDevice(2)=$FileAudio ;$CallIoDeviceTypeFile
  $oSkype.ActiveCalls.Item(1).CaptureMicDevice(2)=$FileMic
  consoleWrite(@crlf & "skype ID:" & $CallID)
  consoleWrite(@crlf & "skype name:" & $CallObj.PartnerHandle)
  consoleWrite(@crlf & "Real Name in:" & $CallObj.PartnerDisplayName)
EndIf
EndFunc
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...