I am working with a TAPI DLL in Python trying to keep track of all the events that happen.
Faced a problem handling ITAddressDeviceSpecificEvent event
<win32com.gen_py.Microsoft TAPI 3.0 Type Library.ITAddressDeviceSpecificEvent instance at 0x274862726400>
print(dir(event))
['Address',' CLSID ',' Call ',' _ApplyTypes_ ',' __class__ ',' __delattr__ ',' __dict__ ',' __dir__ ',' __doc__ ',' __eq__ ',' __
format__ ',' __ge__ ',' __getattr__ ',' __getattribute__ ',' __gt__ ',' __hash__ ',' __init__ ',' __init_subclass__ ',' __iter__
',' __le__ ',' __lt__ ',' __module__ ',' __ne__ ',' __new__ ',' __reduce__ ',' __reduce_ex__ ',' __repr__ ',' __setattr__ ',' __s
izeof__ ',' __str__ ',' __subclasshook__ ',' __weakref__ ',' _get_good_object_ ',' _get_good_single_object_ ',' _oleobj_ ',' _p
rop_map_get_ ',' _prop_map_put_ ',' coclass_clsid ',' lParam1 ',' lParam2 ',' lParam3 ']
print(event.__ dict__)
{'_oleobj_': <PyIDispatch at 0x0000003FFFC10C90 with obj at 0x0000003FFC9EEE50>}
When trying to access Address, Call and lParam ( I get an error
Address
pywintypes.com_error: (-2147352573, 'Member not found.', None, None)
Call
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147221497), None)
And lParam1,2,3
pywintypes.com_error: (-2147352559, 'Does not support a collection.', None, None)
How can data be pulled from this event? With others, the events did not cause problems.
After importing dll to delphi, I looked at the contents of ITAddressDeviceSpecificEvent
// *********************************************************************//
// Interface: ITAddressDeviceSpecificEvent
// Flags: (4352) OleAutomation Dispatchable
// GUID: {3ACB216B-40BD-487A-8672-5CE77BD7E3A3}
// *********************************************************************//
ITAddressDeviceSpecificEvent = interface(IDispatch)
['{3ACB216B-40BD-487A-8672-5CE77BD7E3A3}']
function Get_Address(out ppAddress: ITAddress): HResult; stdcall;
function Get_Call(out ppCall: ITCallInfo): HResult; stdcall;
function Get_lParam1(out pParam1: Integer): HResult; stdcall;
function Get_lParam2(out pParam2: Integer): HResult; stdcall;
function Get_lParam3(out pParam3: Integer): HResult; stdcall;
end;
Does anyone have experience with something like this?
UPD:
I found an example in the C language, but unfortunately I don't understand anything in it, can it somehow be converted into python?
HRESULT STDMETHODCALLTYPE CMyEventNotification::Event(
TAPI_EVENT TapiEvent,
IDispatch * pEvent
)
{
HRESULT hr = S_OK;
//...
switch (TapiEvent)
{
case TE_ADDRESSDEVSPECIFIC:
{
ITAddressDeviceSpecificEvent* pITADSEvent = NULL;
hr = pEvent->QueryInterface(
IID_ITAddressDeviceSpecificEvent,
(void **)(&pITADSEvent) );
// If (hr != S_OK) process the error here...
// Retrieve data received from the TSP.
long lParam1=0;
hr = pITADSEvent->get_lParam1(&lParam1);
// If (hr != S_OK) process the error here...
long lParam2=0;
hr = pITADSEvent->get_lParam2(&lParam2);
// If (hr != S_OK) process the error here...
long lParam3=0;
hr = pITADSEvent->get_lParam3(&lParam3);
// If (hr !=S_OK) process the error here...
// Process the data here.
// ...
pITADSEvent->Release();
break;
}
case TE_PHONEDEVSPECIFIC:
{
ITPhoneDeviceSpecificEvent* pITPhEvent = NULL;
hr = pEvent->QueryInterface(
IID_ITPhoneDeviceSpecificEvent,
(void **)(&pITPhEvent) );
// If (hr != S_OK) process the error here...
// Retrieve data received from the TSP.
long lParam1=0;
hr = pITPhEvent->get_lParam1(&lParam1);
// If (hr != S_OK) process the error here...
long lParam2=0;
hr = pITPhEvent->get_lParam2(&lParam2);
// If (hr != S_OK) process the error here...
long lParam3=0;
hr = pITPhEvent->get_lParam3(&lParam3);
// If (hr != S_OK) process the error here...
// Process the data here.
//...
pITPhEvent->Release();
break;
}
//...
} // end of switch
//...
}
There is no solution. pywin32 is not able to parse dll correctly, from which further work with such events is not possible