Hallo Zusammen,
ich möchte unsere Cisco-Telefonanlage nutzen, um aus einem Programm heraus den Wählvorgang auszulösen.
Hierzu habe ich mich in etwa diesem Script bedient: Tapi3 ... Mal wieder ärger mit Events
Wir nutzen ein Programm, dass "Proffessional Client" heißt. Wenn hier eine Telefonnummer gewählt wird, klingelt das Telefon, man nimmt ab und es wählt raus. Von eingehenden Anrufen rede ich erstmal gar nicht.
Es scheint alles zu funktionieren, aber es tut sich am Telefon nichts.
Erbitte Hilfe.
Hier das modifizierte Programm:
(Hinweis: Das 'Dim m_TAPI As New TAPIClass' musste ich ersetzten durch 'Dim m_Tapi As New TAPI3Lib.TAPI', da sonst ein Fehler auftrat)
ich möchte unsere Cisco-Telefonanlage nutzen, um aus einem Programm heraus den Wählvorgang auszulösen.
Hierzu habe ich mich in etwa diesem Script bedient: Tapi3 ... Mal wieder ärger mit Events
Wir nutzen ein Programm, dass "Proffessional Client" heißt. Wenn hier eine Telefonnummer gewählt wird, klingelt das Telefon, man nimmt ab und es wählt raus. Von eingehenden Anrufen rede ich erstmal gar nicht.
Es scheint alles zu funktionieren, aber es tut sich am Telefon nichts.
Erbitte Hilfe.
Hier das modifizierte Programm:
(Hinweis: Das 'Dim m_TAPI As New TAPIClass' musste ich ersetzten durch 'Dim m_Tapi As New TAPI3Lib.TAPI', da sonst ein Fehler auftrat)
Visual Basic-Quellcode
- Imports TAPI3Lib
- Public Class Form1
- Public Const MediaAudio As Integer = 8
- Public Const MediaModem As Integer = 16
- Public Const MediaFax As Integer = 32
- Public Const MediaVideo As Integer = 32768
- Public WithEvents oTAPI As TAPI3Lib.TAPI
- Public oAddress As ITAddress ' will hold our selected address (you can hold many address in an array)
- Public RegCookie As Integer
- Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- Dim m_Tapi As New TAPI3Lib.TAPI ' creating a new instance to first initialize TAPI befor attaching the events
- Dim MediaTypes As Integer ' a variable to hold supported media types for the address
- m_Tapi.Initialize() ' initializing TAPI
- oTAPI = m_Tapi
- 'oTAPI = m_TAPI ' attaching event sink
- m_Tapi = Nothing
- Dim AddressCollection As ITCollection = oTAPI.Addresses()
- For Each Address As ITAddress In AddressCollection ' looping through address collection
- If Address.State = ADDRESS_STATE.AS_INSERVICE Then ' checking if address is working
- Dim MediaSupport As ITMediaSupport = Address ' extracting meida support interface from the address
- MediaTypes = MediaSupport.MediaTypes ' extracting media types supporting
- MediaSupport = Nothing ' dispose of the object
- If MediaTypes And MediaModem = MediaModem Then ' the address is a data Modem
- If MediaTypes And MediaAudio = MediaAudio Then 'the address supports Audio
- If MsgBox(Address.AddressName, vbYesNo, "Adresse:") = MsgBoxResult.Yes Then ' EDITIERT: AUSWAHL DES DIENSTES
- oAddress = Address ' select this address
- MsgBox("we have selected this address: " + oAddress.AddressName) ' show the selected address name
- Exit For
- End If
- End If
- End If
- End If
- Next Address
- If Not oAddress Is Nothing Then
- ' registering notifications for the selected address
- RegCookie = oTAPI.RegisterCallNotifications(oAddress, True, False, MediaTypes, 1)
- oTAPI.EventFilter = TAPI_EVENT.TE_CALLNOTIFICATION Or TAPI_EVENT.TE_CALLSTATE Or TAPI_EVENT.TE_CALLINFOCHANGE 'Gibt an auf welche Events Tapi reagieren soll
- Else
- MsgBox("no address selected")
- End If
- End Sub
- Private Sub oTAPI_Event(ByVal TapiEvent As TAPI3Lib.TAPI_EVENT, ByVal pEvent As Object) Handles oTAPI.Event
- Select Case TapiEvent
- Case TAPI_EVENT.TE_CALLNOTIFICATION
- MsgBox("oTAPI_Event+ Callnotification")
- Case TAPI_EVENT.TE_CALLSTATE 'Funktioniert, wird ausgelöst, bei newcall.Connect(False)
- MsgBox("oTAPI_Event + Callstate")
- Case TAPI_EVENT.TE_CALLINFOCHANGE
- MsgBox("oTAPI_Event + Callinfochange")
- End Select
- End Sub
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- Dim PhoneNumber As String = "015256458XXX"
- Dim lAddressType As Long = TAPI3Lib.TapiConstants.LINEADDRESSTYPE_PHONENUMBER
- Dim newcall As TAPI3Lib.ITBasicCallControl
- newcall = oAddress.CreateCall(PhoneNumber, TAPI3Lib.TapiConstants.LINEADDRESSTYPE_PHONENUMBER, TAPI3Lib.TapiConstants.TAPIMEDIATYPE_AUDIO)
- newcall.Connect(False)
- End Sub
- End Class