This is very tricky to do in pure-python. Other interfaces with this issue (eg, the shell interfaces) tend to use custom c++ code (often generated by the 'makegw' package then heavily edited) to implement a win32com 'sub-module'. The best alternative for you may be to investigate how comtypes might help...

Cheers,

Mark

On 6/10/2009 2:58 AM, Damon Wischik wrote:
I am trying to use Microsoft's RealTimeStylus COM classes from Python.
I want to access the RealTimeStylus object, and I want to create
Python objects that support the IStylusAsyncPlugin. The difficulty is
that there is no type library specifying the relevant interfaces, nor
is there an IDL file. All I can find are Microsoft's C/C++ header
files in the Windows 7 SDK. My registry has an entry for the CLSID for
RealTimeStylus, but it doesn't have entries for the interfaces
IRealTimeStylus or IStylusAsyncPlugin.

I know very little about COM, but it seems to me that I should be able
to read through the C/C++ header files for the relevant COM
interfaces, and write a Python equivalent. (I don't think I can use
makepy because there is no type library, and I don't think I can use
the Dispatch approach because (a) RealTimeStylus does not implement
IDispatch and (b) that's no use anyway for server COM.)

I know very little about IDL and about COM, and I have no idea how to
go about translating the C/C++ header files into Python. I would be
very grateful if anyone could give me some tips, or pointers about
what I should read to do this, or correct misconceptions in what I
wrote above.

The stuff below is excerpted from rtscom.h, and it looks like the
interface IRealTimeStylus which I would like to use in Python.

Damon.


#ifndef __IRealTimeStylus_INTERFACE_DEFINED__
#define __IRealTimeStylus_INTERFACE_DEFINED__

/* interface IRealTimeStylus */
/* [unique][helpstring][uuid][object] */


EXTERN_C const IID IID_IRealTimeStylus;

#if defined(__cplusplus)&&  !defined(CINTERFACE)

     MIDL_INTERFACE("A8BB5D22-3144-4a7b-93CD-F34A16BE513A")
     IRealTimeStylus : public IUnknown
     {
     public:
         virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_Enabled(
             /* [retval][out] */ __RPC__out BOOL *pfEnable) = 0;

         virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_Enabled(
             /* [in] */ BOOL fEnable) = 0;

         virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_HWND(
             /* [retval][out] */ __RPC__out HANDLE_PTR *phwnd) = 0;

         virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_HWND(
             /* [in] */ HANDLE_PTR hwnd) = 0;

         virtual /* [propget] */ HRESULT STDMETHODCALLTYPE
get_WindowInputRectangle(
             /* [retval][out] */ __RPC__out RECT *prcWndInputRect) = 0;

         virtual /* [propput] */ HRESULT STDMETHODCALLTYPE
put_WindowInputRectangle(
             /* [in] */ __RPC__in const RECT *prcWndInputRect) = 0;

         virtual HRESULT STDMETHODCALLTYPE AddStylusSyncPlugin(
             /* [in] */ ULONG iIndex,
             /* [in] */ __RPC__in_opt IStylusSyncPlugin *piPlugin) = 0;

         virtual HRESULT STDMETHODCALLTYPE RemoveStylusSyncPlugin(
             /* [in] */ ULONG iIndex,
             /* [out][in] */ __RPC__deref_inout_opt IStylusSyncPlugin
**ppiPlugin) = 0;

         virtual HRESULT STDMETHODCALLTYPE RemoveAllStylusSyncPlugins( void) = 
0;

         virtual HRESULT STDMETHODCALLTYPE GetStylusSyncPlugin(
             /* [in] */ ULONG iIndex,
             /* [out] */ __RPC__deref_out_opt IStylusSyncPlugin **ppiPlugin) = 
0;

         virtual HRESULT STDMETHODCALLTYPE GetStylusSyncPluginCount(
             /* [out] */ __RPC__out ULONG *pcPlugins) = 0;

         virtual HRESULT STDMETHODCALLTYPE AddStylusAsyncPlugin(
             /* [in] */ ULONG iIndex,
             /* [in] */ __RPC__in_opt IStylusAsyncPlugin *piPlugin) = 0;

         virtual HRESULT STDMETHODCALLTYPE RemoveStylusAsyncPlugin(
             /* [in] */ ULONG iIndex,
             /* [out][in] */ __RPC__deref_inout_opt IStylusAsyncPlugin
**ppiPlugin) = 0;

         virtual HRESULT STDMETHODCALLTYPE RemoveAllStylusAsyncPlugins(
void) = 0;

         virtual HRESULT STDMETHODCALLTYPE GetStylusAsyncPlugin(
             /* [in] */ ULONG iIndex,
             /* [out] */ __RPC__deref_out_opt IStylusAsyncPlugin
**ppiPlugin) = 0;

         virtual HRESULT STDMETHODCALLTYPE GetStylusAsyncPluginCount(
             /* [out] */ __RPC__out ULONG *pcPlugins) = 0;

         virtual /* [propget] */ HRESULT STDMETHODCALLTYPE
get_ChildRealTimeStylusPlugin(
             /* [retval][out] */ __RPC__deref_out_opt IRealTimeStylus
**ppiRTS) = 0;

         virtual /* [propputref] */ HRESULT STDMETHODCALLTYPE
putref_ChildRealTimeStylusPlugin(
             /* [unique][in] */ __RPC__in_opt IRealTimeStylus *piRTS) = 0;

         virtual HRESULT STDMETHODCALLTYPE AddCustomStylusDataToQueue(
             /* [in] */ StylusQueue sq,
             /* [in] */ __RPC__in const GUID *pGuidId,
             /* [range][in] */ __RPC__in_range(0,0x7fff) ULONG cbData,
             /* [unique][size_is][in] */
__RPC__in_ecount_full_opt(cbData) BYTE *pbData) = 0;

         virtual HRESULT STDMETHODCALLTYPE ClearStylusQueues( void) = 0;

         virtual HRESULT STDMETHODCALLTYPE SetAllTabletsMode(
             /* [in] */ BOOL fUseMouseForInput) = 0;

         virtual HRESULT STDMETHODCALLTYPE SetSingleTabletMode(
             /* [in] */ __RPC__in_opt IInkTablet *piTablet) = 0;

         virtual HRESULT STDMETHODCALLTYPE GetTablet(
             /* [retval][out] */ __RPC__deref_out_opt IInkTablet
**ppiSingleTablet) = 0;

         virtual HRESULT STDMETHODCALLTYPE GetTabletContextIdFromTablet(
             /* [in] */ __RPC__in_opt IInkTablet *piTablet,
             /* [retval][out] */ __RPC__out TABLET_CONTEXT_ID *ptcid) = 0;

         virtual HRESULT STDMETHODCALLTYPE GetTabletFromTabletContextId(
             /* [in] */ TABLET_CONTEXT_ID tcid,
             /* [retval][out] */ __RPC__deref_out_opt IInkTablet
**ppiTablet) = 0;

         virtual HRESULT STDMETHODCALLTYPE GetAllTabletContextIds(
             /* [out][in] */ __RPC__inout ULONG *pcTcidCount,
             /* [size_is][size_is][out] */
__RPC__deref_out_ecount_full_opt(*pcTcidCount) TABLET_CONTEXT_ID
**ppTcids) = 0;

         virtual HRESULT STDMETHODCALLTYPE GetStyluses(
             /* [retval][out] */ __RPC__deref_out_opt IInkCursors
**ppiInkCursors) = 0;

         virtual HRESULT STDMETHODCALLTYPE GetStylusForId(
             /* [in] */ STYLUS_ID sid,
             /* [retval][out] */ __RPC__deref_out_opt IInkCursor
**ppiInkCursor) = 0;

         virtual HRESULT STDMETHODCALLTYPE SetDesiredPacketDescription(
             /* [range][in] */ __RPC__in_range(0,32) ULONG cProperties,
             /* [size_is][in] */ __RPC__in_ecount_full(cProperties)
const GUID *pPropertyGuids) = 0;

         virtual HRESULT STDMETHODCALLTYPE GetDesiredPacketDescription(
             /* [out][in] */ __RPC__inout ULONG *pcProperties,
             /* [size_is][size_is][out] */
__RPC__deref_out_ecount_full_opt(*pcProperties) GUID
**ppPropertyGuids) = 0;

         virtual HRESULT STDMETHODCALLTYPE GetPacketDescriptionData(
             /* [in] */ TABLET_CONTEXT_ID tcid,
             /* [unique][out][in] */ __RPC__inout_opt FLOAT 
*pfInkToDeviceScaleX,
             /* [unique][out][in] */ __RPC__inout_opt FLOAT 
*pfInkToDeviceScaleY,
             /* [out][in] */ __RPC__inout ULONG *pcPacketProperties,
             /* [size_is][size_is][out] */
__RPC__deref_out_ecount_full_opt(*pcPacketProperties) PACKET_PROPERTY
**ppPacketProperties) = 0;

     };

#else   /* C style interface */

     typedef struct IRealTimeStylusVtbl
     {
         BEGIN_INTERFACE

         HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
             __RPC__in IRealTimeStylus * This,
             /* [in] */ __RPC__in REFIID riid,
             /* [annotation][iid_is][out] */
             __RPC__deref_out  void **ppvObject);

         ULONG ( STDMETHODCALLTYPE *AddRef )(
             __RPC__in IRealTimeStylus * This);

         ULONG ( STDMETHODCALLTYPE *Release )(
             __RPC__in IRealTimeStylus * This);

         /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_Enabled )(
             __RPC__in IRealTimeStylus * This,
             /* [retval][out] */ __RPC__out BOOL *pfEnable);

         /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_Enabled )(
             __RPC__in IRealTimeStylus * This,
             /* [in] */ BOOL fEnable);

         /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_HWND )(
             __RPC__in IRealTimeStylus * This,
             /* [retval][out] */ __RPC__out HANDLE_PTR *phwnd);

         /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_HWND )(
             __RPC__in IRealTimeStylus * This,
             /* [in] */ HANDLE_PTR hwnd);

         /* [propget] */ HRESULT ( STDMETHODCALLTYPE
*get_WindowInputRectangle )(
             __RPC__in IRealTimeStylus * This,
             /* [retval][out] */ __RPC__out RECT *prcWndInputRect);

         /* [propput] */ HRESULT ( STDMETHODCALLTYPE
*put_WindowInputRectangle )(
             __RPC__in IRealTimeStylus * This,
             /* [in] */ __RPC__in const RECT *prcWndInputRect);

         HRESULT ( STDMETHODCALLTYPE *AddStylusSyncPlugin )(
             __RPC__in IRealTimeStylus * This,
             /* [in] */ ULONG iIndex,
             /* [in] */ __RPC__in_opt IStylusSyncPlugin *piPlugin);

         HRESULT ( STDMETHODCALLTYPE *RemoveStylusSyncPlugin )(
             __RPC__in IRealTimeStylus * This,
             /* [in] */ ULONG iIndex,
             /* [out][in] */ __RPC__deref_inout_opt IStylusSyncPlugin
**ppiPlugin);

         HRESULT ( STDMETHODCALLTYPE *RemoveAllStylusSyncPlugins )(
             __RPC__in IRealTimeStylus * This);

         HRESULT ( STDMETHODCALLTYPE *GetStylusSyncPlugin )(
             __RPC__in IRealTimeStylus * This,
             /* [in] */ ULONG iIndex,
             /* [out] */ __RPC__deref_out_opt IStylusSyncPlugin **ppiPlugin);

         HRESULT ( STDMETHODCALLTYPE *GetStylusSyncPluginCount )(
             __RPC__in IRealTimeStylus * This,
             /* [out] */ __RPC__out ULONG *pcPlugins);

         HRESULT ( STDMETHODCALLTYPE *AddStylusAsyncPlugin )(
             __RPC__in IRealTimeStylus * This,
             /* [in] */ ULONG iIndex,
             /* [in] */ __RPC__in_opt IStylusAsyncPlugin *piPlugin);

         HRESULT ( STDMETHODCALLTYPE *RemoveStylusAsyncPlugin )(
             __RPC__in IRealTimeStylus * This,
             /* [in] */ ULONG iIndex,
             /* [out][in] */ __RPC__deref_inout_opt IStylusAsyncPlugin
**ppiPlugin);

         HRESULT ( STDMETHODCALLTYPE *RemoveAllStylusAsyncPlugins )(
             __RPC__in IRealTimeStylus * This);

         HRESULT ( STDMETHODCALLTYPE *GetStylusAsyncPlugin )(
             __RPC__in IRealTimeStylus * This,
             /* [in] */ ULONG iIndex,
             /* [out] */ __RPC__deref_out_opt IStylusAsyncPlugin **ppiPlugin);

         HRESULT ( STDMETHODCALLTYPE *GetStylusAsyncPluginCount )(
             __RPC__in IRealTimeStylus * This,
             /* [out] */ __RPC__out ULONG *pcPlugins);

         /* [propget] */ HRESULT ( STDMETHODCALLTYPE
*get_ChildRealTimeStylusPlugin )(
             __RPC__in IRealTimeStylus * This,
             /* [retval][out] */ __RPC__deref_out_opt IRealTimeStylus **ppiRTS);

         /* [propputref] */ HRESULT ( STDMETHODCALLTYPE
*putref_ChildRealTimeStylusPlugin )(
             __RPC__in IRealTimeStylus * This,
             /* [unique][in] */ __RPC__in_opt IRealTimeStylus *piRTS);

         HRESULT ( STDMETHODCALLTYPE *AddCustomStylusDataToQueue )(
             __RPC__in IRealTimeStylus * This,
             /* [in] */ StylusQueue sq,
             /* [in] */ __RPC__in const GUID *pGuidId,
             /* [range][in] */ __RPC__in_range(0,0x7fff) ULONG cbData,
             /* [unique][size_is][in] */
__RPC__in_ecount_full_opt(cbData) BYTE *pbData);

         HRESULT ( STDMETHODCALLTYPE *ClearStylusQueues )(
             __RPC__in IRealTimeStylus * This);

         HRESULT ( STDMETHODCALLTYPE *SetAllTabletsMode )(
             __RPC__in IRealTimeStylus * This,
             /* [in] */ BOOL fUseMouseForInput);

         HRESULT ( STDMETHODCALLTYPE *SetSingleTabletMode )(
             __RPC__in IRealTimeStylus * This,
             /* [in] */ __RPC__in_opt IInkTablet *piTablet);

         HRESULT ( STDMETHODCALLTYPE *GetTablet )(
             __RPC__in IRealTimeStylus * This,
             /* [retval][out] */ __RPC__deref_out_opt IInkTablet
**ppiSingleTablet);

         HRESULT ( STDMETHODCALLTYPE *GetTabletContextIdFromTablet )(
             __RPC__in IRealTimeStylus * This,
             /* [in] */ __RPC__in_opt IInkTablet *piTablet,
             /* [retval][out] */ __RPC__out TABLET_CONTEXT_ID *ptcid);

         HRESULT ( STDMETHODCALLTYPE *GetTabletFromTabletContextId )(
             __RPC__in IRealTimeStylus * This,
             /* [in] */ TABLET_CONTEXT_ID tcid,
             /* [retval][out] */ __RPC__deref_out_opt IInkTablet **ppiTablet);

         HRESULT ( STDMETHODCALLTYPE *GetAllTabletContextIds )(
             __RPC__in IRealTimeStylus * This,
             /* [out][in] */ __RPC__inout ULONG *pcTcidCount,
             /* [size_is][size_is][out] */
__RPC__deref_out_ecount_full_opt(*pcTcidCount) TABLET_CONTEXT_ID
**ppTcids);

         HRESULT ( STDMETHODCALLTYPE *GetStyluses )(
             __RPC__in IRealTimeStylus * This,
             /* [retval][out] */ __RPC__deref_out_opt IInkCursors
**ppiInkCursors);

         HRESULT ( STDMETHODCALLTYPE *GetStylusForId )(
             __RPC__in IRealTimeStylus * This,
             /* [in] */ STYLUS_ID sid,
             /* [retval][out] */ __RPC__deref_out_opt IInkCursor 
**ppiInkCursor);

         HRESULT ( STDMETHODCALLTYPE *SetDesiredPacketDescription )(
             __RPC__in IRealTimeStylus * This,
             /* [range][in] */ __RPC__in_range(0,32) ULONG cProperties,
             /* [size_is][in] */ __RPC__in_ecount_full(cProperties)
const GUID *pPropertyGuids);

         HRESULT ( STDMETHODCALLTYPE *GetDesiredPacketDescription )(
             __RPC__in IRealTimeStylus * This,
             /* [out][in] */ __RPC__inout ULONG *pcProperties,
             /* [size_is][size_is][out] */
__RPC__deref_out_ecount_full_opt(*pcProperties) GUID
**ppPropertyGuids);

         HRESULT ( STDMETHODCALLTYPE *GetPacketDescriptionData )(
             __RPC__in IRealTimeStylus * This,
             /* [in] */ TABLET_CONTEXT_ID tcid,
             /* [unique][out][in] */ __RPC__inout_opt FLOAT 
*pfInkToDeviceScaleX,
             /* [unique][out][in] */ __RPC__inout_opt FLOAT 
*pfInkToDeviceScaleY,
             /* [out][in] */ __RPC__inout ULONG *pcPacketProperties,
             /* [size_is][size_is][out] */
__RPC__deref_out_ecount_full_opt(*pcPacketProperties) PACKET_PROPERTY
**ppPacketProperties);

         END_INTERFACE
     } IRealTimeStylusVtbl;

     interface IRealTimeStylus
     {
         CONST_VTBL struct IRealTimeStylusVtbl *lpVtbl;
     };
_______________________________________________
python-win32 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-win32

_______________________________________________
python-win32 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to