Sign in to follow this  
Followers 0
DK12000

Sype4COM object syntax, help please

1 post in this topic

#1 ·  Posted (edited)

I am just about finished my Skype to Growl project but the ability to record a Skype call has been driving me mad. I'm not that good with COM stuff and was hoping that someone who is could take a quick look at this for me and spot any obvious mistakes.

I have made use of Airwolf's excellent Skype4COM examples and I have set-up a test script just to get the incoming and mic audio to record.

It attaches to the Skype API using the Skype4COM .dll API wrapper, the Skype4COM help file is in the zip.

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 am sure its just me but I have tried many different variations and cant get it to work.

I've included several pieces of code that I've found in my research that are supposed to work for C# and VB.

Any help will be very, very much appreciated and a shout out for the person who solves it will go into the final release. :x

TL;DR version : These dont work

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

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

#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");
;--------------------------------
Edited by DK12000

Share this post


Link to post
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
Sign in to follow this  
Followers 0