Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #73476 > unrolled thread

comtypes

Started bypeter.balazovic@emspin.com
First post2014-06-21 00:08 -0700
Last post2014-06-21 12:08 -0700
Articles 5 — 3 participants

Back to article view | Back to comp.lang.python


Contents

  comtypes peter.balazovic@emspin.com - 2014-06-21 00:08 -0700
    Re: comtypes John Gordon <gordon@panix.com> - 2014-06-21 16:34 +0000
      Re: comtypes peter.balazovic@emspin.com - 2014-06-21 10:09 -0700
    Re: comtypes Thomas Heller <theller@ctypes.org> - 2014-06-21 20:17 +0200
      Re: comtypes peter.balazovic@emspin.com - 2014-06-21 12:08 -0700

#73476 — comtypes

Frompeter.balazovic@emspin.com
Date2014-06-21 00:08 -0700
Subjectcomtypes
Message-ID<7b0712bf-68b0-4183-860d-2a39d22b62f4@googlegroups.com>
Dears,

I am not sure I am at right place here. Now I've started working with comtypes 1.1.0 package within python 2.7.6.1. I have ActiveX COM object I want access and work with it.

I do following 
>> from comtypes.client import CreateObject
>> fm = CreateObject("MCB.PCM")
>> dwt = fm.ReadVariable("dwt")
>> print dwt
(<comtypes.automation.LP_tagVARIANT object at 0x05A8E1C0>, <comtypes.automation.LP_tagVARIANT object at 0x05A8E210>, <comtypes.automation.LP_tagVARIANT object at 0x05A8E260>, True)
 
by using print gives me return values. I want to access return data (array)and  variable. How can I correctly handle it?

I would you be very thankful for your help.

Thank you
Peter

ReadVariable = [Variant, Variant, Variant, Variant] ReadVariable(handle, Variant)

[toc] | [next] | [standalone]


#73478

FromJohn Gordon <gordon@panix.com>
Date2014-06-21 16:34 +0000
Message-ID<lo4c6q$rdk$1@reader1.panix.com>
In reply to#73476
In <7b0712bf-68b0-4183-860d-2a39d22b62f4@googlegroups.com> peter.balazovic@emspin.com writes:

> >> print dwt
> (<comtypes.automation.LP_tagVARIANT object at 0x05A8E1C0>, <comtypes.automation.LP_tagVARIANT object at 0x05A8E210>, <comtypes.automation.LP_tagVARIANT object at 0x05A8E260>, True)
>  
> by using print gives me return values. I want to access return data
> (array)and variable. How can I correctly handle it?

You can use help() and dir() to display more information about an object.

-- 
John Gordon         Imagine what it must be like for a real medical doctor to
gordon@panix.com    watch 'House', or a real serial killer to watch 'Dexter'.

[toc] | [prev] | [next] | [standalone]


#73479

Frompeter.balazovic@emspin.com
Date2014-06-21 10:09 -0700
Message-ID<9eda1f3c-bd06-4b5e-b627-4392953333dc@googlegroups.com>
In reply to#73478
Hmm, I did that - oleviewer says

[id(0x60020002)]
HRESULT ReadVariable(
                [in] VARIANT bsVar, 
                [out, optional] VARIANT* vValue, 
                [out, optional] VARIANT* tValue, 
                [out, optional] VARIANT* bsRetMsg, 
                [out, retval] VARIANT* pOk);

ipython 
>>help(fm.ReadVariable)
Help on method ReadVariable in module ctypes:

ReadVariable(...) method of comtypes.POINTER(IMcbPcm) instance


Still I try to figure out how to handle it in python
Peter

On Saturday, June 21, 2014 6:34:34 PM UTC+2, John Gordon wrote:
> In <7b0712bf-68b0-4183-860d-2a39d22b62f4@googlegroups.com> peter.balazovic@emspin.com writes:
> 
> 
> 
> > >> print dwt
> 
> > (<comtypes.automation.LP_tagVARIANT object at 0x05A8E1C0>, <comtypes.automation.LP_tagVARIANT object at 0x05A8E210>, <comtypes.automation.LP_tagVARIANT object at 0x05A8E260>, True)
> 
> >  
> 
> > by using print gives me return values. I want to access return data
> 
> > (array)and variable. How can I correctly handle it?
> 
> 
> 
> You can use help() and dir() to display more information about an object.
> 
> 
> 
> -- 
> 
> John Gordon         Imagine what it must be like for a real medical doctor to
> 
> gordon@panix.com    watch 'House', or a real serial killer to watch 'Dexter'.

[toc] | [prev] | [next] | [standalone]


#73480

FromThomas Heller <theller@ctypes.org>
Date2014-06-21 20:17 +0200
Message-ID<c0m0cuFku88U1@mid.individual.net>
In reply to#73476
Am 21.06.2014 09:08, schrieb peter.balazovic@emspin.com:
> Dears,
>
> I am not sure I am at right place here. Now I've started working with comtypes 1.1.0 package within python 2.7.6.1. I have ActiveX COM object I want access and work with it.
>
> I do following
>>> from comtypes.client import CreateObject
>>> fm = CreateObject("MCB.PCM")
>>> dwt = fm.ReadVariable("dwt")
>>> print dwt
> (<comtypes.automation.LP_tagVARIANT object at 0x05A8E1C0>, <comtypes.automation.LP_tagVARIANT object at 0x05A8E210>, <comtypes.automation.LP_tagVARIANT object at 0x05A8E260>, True)
>
> by using print gives me return values. I want to access return data (array)and  variable. How can I correctly handle it?

dwt apparently is an array containing pointers to VARIANTs.  In
comtypes (or ctypes) you dereference pointer by indexing them with zero.
So something like this could work:

for item in dwt:
     print item[0]

Thomas

[toc] | [prev] | [next] | [standalone]


#73481

Frompeter.balazovic@emspin.com
Date2014-06-21 12:08 -0700
Message-ID<b08e7948-57db-4f5d-ad76-49432c58fe8b@googlegroups.com>
In reply to#73480
I uses pywin32

>>> import win32com.client
>>> fm = win32com.client.Dispatch("MCB.PCM")
>>> fm.ReadVariable('dwt')
(True, 0.02500000037252903, u'0.025', u'')

and I am getting it OK.

Now I am trying to add and register event handler and no luck yet :(

>>> ev  = win32com.client.WithEvents(fm, evnt)

class evnt:
    def OnEvent(self):
        print "Hello..."

  
it does not work... I would like to know correct way to register event - any idea?

Thank you very much.


On Saturday, June 21, 2014 8:17:23 PM UTC+2, Thomas Heller wrote:
> Am 21.06.2014 09:08, schrieb peter.balazovic@emspin.com:
> 
> > Dears,
> 
> >
> 
> > I am not sure I am at right place here. Now I've started working with comtypes 1.1.0 package within python 2.7.6.1. I have ActiveX COM object I want access and work with it.
> 
> >
> 
> > I do following
> 
> >>> from comtypes.client import CreateObject
> 
> >>> fm = CreateObject("MCB.PCM")
> 
> >>> dwt = fm.ReadVariable("dwt")
> 
> >>> print dwt
> 
> > (<comtypes.automation.LP_tagVARIANT object at 0x05A8E1C0>, <comtypes.automation.LP_tagVARIANT object at 0x05A8E210>, <comtypes.automation.LP_tagVARIANT object at 0x05A8E260>, True)
> 
> >
> 
> > by using print gives me return values. I want to access return data (array)and  variable. How can I correctly handle it?
> 
> 
> 
> dwt apparently is an array containing pointers to VARIANTs.  In
> 
> comtypes (or ctypes) you dereference pointer by indexing them with zero.
> 
> So something like this could work:
> 
> 
> 
> for item in dwt:
> 
>      print item[0]
> 
> 
> 
> Thomas

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web