Sign in to follow this  
Followers 0
OmarOrn

tapi control via dll or activex pbx

2 posts in this topic

#1 ·  Posted (edited)

Hi i am trying to program a tool to control my pbx with tapi, i found an dll\ocx but am not sure how to implement it.

 

i wil include the code and my progress so far i now i have taken this example from a html sample and am trying to convert it.

and here is where i am at with the script im not sure how to imblement the ocx file.

 

; ----------------------------------------------------------------------------
;
; VBScript to AutoIt Converter v0.4
;
; ----------------------------------------------------------------------------

#include <date.au3>
$topTapi1 = ObjCreate("c:\windows\toptapi2.ocx")
dim $ThisForm 
dim $Document

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("phonetest", 379, 445, 193, 125)
$comb_taeki = GUICtrlCreateCombo("comb_taeki", 32, 32, 145, 25)
$btn_dial = GUICtrlCreateButton("Dial", 32, 80, 75, 25, 0)
$inp_dial = GUICtrlCreateInput("inp_dial", 120, 80, 121, 21)
$Btn_drop = GUICtrlCreateButton("Drop", 24, 120, 75, 25, 0)
$btn_answer = GUICtrlCreateButton("Answer", 104, 120, 75, 25, 0)
$btn_hold = GUICtrlCreateButton("Hold", 184, 120, 75, 25, 0)
$Button4 = GUICtrlCreateButton("unhold", 264, 120, 75, 25, 0)
$Trace = GUICtrlCreateLabel("Trace", 24, 168, 32, 17)
$btn_del = GUICtrlCreateButton("del", 8, 192, 27, 25, 0)
$tra_box = GUICtrlCreateEdit("", 8, 224, 297, 201)
GUICtrlSetData(-1, "tra_box")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

;-- Flags for TapiLineOpen --;
 Const $FL_ACCBEFOREALERT = 1     
 Const $FL_DROPONDISCONNECT = 2   
 Const $FL_DROPONBUSY = 4
 Const $FL_AUTODEALLOC = 8
 Const $FL_AUTOOWNER = 10
 Const $FL_PHONEOPEN = 20
;-- MediaModes --;
 Const $LINEMEDIAMODE_UNKNOWN = 2
 Const $LINEMEDIAMODE_INTERACTIVEVOICE = 4
 Const $LINEMEDIAMODE_AUTOMATEDVOICE = 8
 Const $LINEMEDIAMODE_DATAMODEM = 10
 Const $LINEMEDIAMODE_G3FAX = 20
 Const $LINEMEDIAMODE_TDD = 40
 Const $LINEMEDIAMODE_G4FAX = 80
 Const $LINEMEDIAMODE_DIGITALDATA = 100
 Const $LINEMEDIAMODE_TELETEX = 200
 Const $LINEMEDIAMODE_VIDEOTEX = 400
 Const $LINEMEDIAMODE_TELEX = 800
 Const $LINEMEDIAMODE_MIXED = 1000
 Const $LINEMEDIAMODE_ADSI = 2000
 Const $LINEMEDIAMODE_VOICEVIEW = 4000
 Const $LINEMEDIAMODE_VIDEO = 8000
;-- Call privilegs --;
 Const $LINECALLPRIVILEGE_NONE = 1
 Const $LINECALLPRIVILEGE_MONITOR = 2
 Const $LINECALLPRIVILEGE_OWNER = 4

DIM $nDeviceID
$nDeviceID=0


;-------------------------------------------------------------------------
Func window_onunload()
   $topTapi1.TapiLineClose(int($nDeviceID))
   $topTapi1.TapiLineShutdown()
EndFunc
;-------------------------------------------------------------------------


;-------------------------------------------------------------------------
Func window_onload()
     $topTapi1.TapiLineInitEx(0,0)
    $ThisForm.textfield.Value = $ThisForm.textfield.Value  &  "TapiLineInitEx found: " &  $topTapi1.DeviceCount & " lines" & @CRLF
    FillDeviceList()
EndFunc
;-------------------------------------------------------------------------


;-------------------------------------------------------------------------
Func cmdDial_onclick()
     $topTapi1.TapiLineDial(int($nDeviceID),$ThisForm.ctlNumber.value,0)
EndFunc
;-------------------------------------------------------------------------


;-------------------------------------------------------------------------
Func cmdDrop_onclick()
     $topTapi1.TapiLineDrop(int($nDeviceID))
EndFunc
;-------------------------------------------------------------------------


;-------------------------------------------------------------------------
Func cmdAnswer_onclick()
     $topTapi1.TapiLineAnswer(int($nDeviceID),0)
EndFunc
;-------------------------------------------------------------------------


;-------------------------------------------------------------------------
Func cmdHold_onclick()
     $topTapi1.TapiLineHold(int($nDeviceID),0)
EndFunc
;-------------------------------------------------------------------------


;-------------------------------------------------------------------------
Func cmdUnHold_onclick()
     $topTapi1.TapiLineUnHold(int($nDeviceID),0)
EndFunc
;-------------------------------------------------------------------------


;-------------------------------------------------------------------------
Func selDevices_onchange()
     $topTapi1.TapiLineClose(int($nDeviceID))
    $nDeviceID=$ThisForm.selDevices.Value
     $topTapi1.TapiLineOpen(int($nDeviceID), $LINEMEDIAMODE_INTERACTIVEVOICE, $LINECALLPRIVILEGE_OWNER or $LINECALLPRIVILEGE_MONITOR, $FL_AUTODEALLOC or  $FL_ACCBEFOREALERT)
EndFunc
;-------------------------------------------------------------------------


;-------------------------------------------------------------------------
Func FillDeviceList()
  Dim $x  

  For $x = 0 To $topTapi1.DeviceCount -1
     $ListItem = $document.createElement("OPTION")
    $ListItem.Text = $topTapi1.getDeviceName(int($x))
    $ListItem.Value = $x
    $ThisForm.selDevices.add ($ListItem)
  Next

EndFunc
;-------------------------------------------------------------------------


;-------------------------------------------------------------------------
Func cmdDelTrace_onclick()
    $ThisForm.textfield.Value = ""
EndFunc
;-------------------------------------------------------------------------


;##  begin topTapi events  ###############

;-------------------------------------------------------------------------
Func topTapi1_OnTapiMessage($CDeviceId, $CCallHandle, $CMessage, $CfromProc, $CErrNumber)
  $ThisForm.textfield.Value = $ThisForm.textfield.Value  & $CfromProc & " -> " & $CMessage & @CRLF 
EndFunc
;-------------------------------------------------------------------------


;-------------------------------------------------------------------------
Func topTapi1_OnCallState($CDeviceId, $CCallHandle, $CCallId, $CCallState)
Dim $strCallState
  $strCallState= $topTapi1.getStrFromValue(1, int($CCallState))
  $ThisForm.textfield.Value = $ThisForm.textfield.Value & "OnCallState DeviceId: " & $CDeviceId & " CallHandle: " & $CCallHandle & " -> " & $strCallState & @CRLF 
EndFunc
;-------------------------------------------------------------------------


;-------------------------------------------------------------------------
Func topTapi1_OnCallerID($CDeviceId, $CCallHandle, $CCallId, $CNumber, $CName, $CPartyId)
  $ThisForm.textfield.Value = $ThisForm.textfield.Value & "OnCallerId DeviceId: " & $CDeviceId & " CallHandle: " & $CCallHandle & " -> " & $CNumber & @CRLF 
EndFunc
;-------------------------------------------------------------------------


;-------------------------------------------------------------------------
Func topTapi1_OnConnectedID($CDeviceId, $CCallHandle, $CCallId, $CNumber, $CName, $CPartyId)
 $ThisForm.textfield.Value = $ThisForm.textfield.Value & "OnConnectedId DeviceId: " & $CDeviceId & " CallHandle: " & $CCallHandle & " -> " & $CNumber & @CRLF 
EndFunc
;-------------------------------------------------------------------------




;##  end topTapi Events  #################

 

i am useing the activex feture from Toptapi

 

with thanks in advance

 

Omar

Edited by Jos

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Do you have any links to usage in VBS (not VB)?

 

:)

Edited by Jos

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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