0

我正在使用 Python 中的TAPI DLL尝试跟踪发生的所有事件。

处理ITAddressDeviceSpecificEvent事件时遇到问题

<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>}

尝试访问地址、呼叫和 lParam时(我收到一个错误

地址

pywintypes.com_error: (-2147352573, 'Member not found.', None, None)

称呼

pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147221497), None)

lParam1 ,2,3

pywintypes.com_error: (-2147352559, 'Does not support a collection.', None, None)

如何从这个事件中提取数据?对于其他人来说,这些事件并没有引起问题。

将dll导入delphi后,查看了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;

有没有人有这样的经验?

升级版:

找了个C语言的例子,可惜里面什么都不懂,能不能转成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 
    //...
}
4

1 回答 1

0

没有解决办法。pywin32 无法正确解析 dll,因此无法进一步处理此类事件

于 2021-10-07T18:13:25.057 回答