comtypes
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
(,
,
, 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)
--
https://mail.python.org/mailman/listinfo/python-list
Re: comtypes
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 <[email protected]> > [email protected] writes: > > > > > >> print dwt > > > (, > > , > > , 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 > > [email protected] 'House', or a real serial killer to watch 'Dexter'. -- https://mail.python.org/mailman/listinfo/python-list
Re: comtypes
I uses pywin32
>>> import win32com.client
>>> fm = win32com.client.Dispatch("MCB.PCM")
>>> fm.ReadVariable('dwt')
(True, 0.0250037252903, 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 [email protected]:
>
> > 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
>
> > (,
> > ,
> > , 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
--
https://mail.python.org/mailman/listinfo/python-list
Event handling for COM object with win32com (pywin32)
Dears,
I have a problem with firing Events and event handling on COM object.
This code works on python console but there is no event fired.
>>> class fmstrEvents(object):
... def OnRecroderDone(self):
... print "Hello OnRecroderDone"
>>> import win32com.client
>>> fm = win32com.client.Dispatch("MCB.PCM")
>>> fm_events = win32com.client.WithEvents(fm,fmstrEvents)
The application fmstr with COM Object "MCB.PCM" is freezing by events handling
within python by pywin32.
Do I miss something in code or incorrectly handling the events or COM Object?
Thank you very much.
Peter
--
https://mail.python.org/mailman/listinfo/python-list
Re: Event handling for COM object with win32com (pywin32)
On Sunday, June 22, 2014 12:09:51 PM UTC+2, Chris Angelico wrote: > On Sun, Jun 22, 2014 at 7:15 PM, wrote: > > > This code works on python console but there is no event fired. > > > > > class fmstrEvents(object): > > > ... def OnRecroderDone(self): > > > ... print "Hello OnRecroderDone" > > > > Is that supposed to say "OnRecroderDone" or "OnRecorderDone"? I can't > > find any Google hits for the former, other than this exact question > > (which you seem to have also posted to StackOverflow - I'm counting > > that as the same), and the latter would be a much more obvious > > spelling. > > > > ChrisA You right, this is a typo here - I am sorry for this but event handler does not work... fmstr application is freezing and event handler does not work. I need to restart python to unfreeze my application. Peter -- https://mail.python.org/mailman/listinfo/python-list
