実際の例は次のようになります (CiscoTSP での作業)
import win32com.client
cls="TAPI.TAPI.1"
# need for gen_py
ti = win32com.client.Dispatch(cls)._oleobj_.GetTypeInfo()
tlb, index = ti.GetContainingTypeLib()
tla = tlb.GetLibAttr()
win32com.client.gencache.EnsureModule(tla[0], tla[1], tla[3], tla[4], bValidateFile=0)
class TapiEvents(win32com.client.getevents(cls)):
def OnEvent(self, ev1,ev2):
print "OnEvent"
tapi=win32com.client.Dispatch(cls)
tapi.Initialize() # must run after Dispatch and before TapiEvents
events=TapiEvents(tapi)
tapi.EventFilter = 0x1FFFF
for addr in tapi.Addresses:
try:
tapi.RegisterCallNotifications(addr,True,True,8,0)
except:
pass
import Tix
r=Tix.Tk()
r.mainloop()
通話利用のため
import win32com.client,time
tapi = win32com.client.Dispatch("TAPI.TAPI.1")
tapi.Initialize()
for item in tapi.Addresses: print item.AddressName
objCrtAddress = [item for item in tapi.Addresses if 'SEP' in item.AddressName][0]
sNumber='323'
gobjCall = objCrtAddress.CreateCall(sNumber, 1, 0x8)
gobjCall.Connect (False)