[python-win32] How to use GetProperty and PutProperty COM interface in IE?

Richard Bell rbell01824 at earthlink.net
Thu May 31 00:24:15 CEST 2007


I'm having trouble using the GetProperty and PutProperty COM interfaces with
IE.  Example:

>>> import win32com.client
>>> ie = win32com.client.Dispatch('InternetExplorer.Application')
>>> ie.visible
>>> ie.Navigate('www.google.com')

So there's an IE with a loaded page.

>>> dir(ie)
['CLSID', 'ClientToWindow', 'ExecWB', 'GetProperty', 'GoBack', 'GoForward',
'GoHome', 'GoSearch', 'Navigate', 'Navigate2', 'PutProperty',
'QueryStatusWB', 'Quit', 'Refresh', 'Refresh2', 'ShowBrowserBar', 'Stop',
'_ApplyTypes_', '__call__', '__cmp__', '__doc__', '__getattr__', '__init__',
'__int__', '__module__', '__repr__', '__setattr__', '__str__',
'__unicode__', '_get_good_object_', '_get_good_single_object_', '_oleobj_',
'_prop_map_get_', '_prop_map_put_', 'coclass_clsid']

Clearly there are GetProperty and PutProperty methods.

>>> ie._prop_map_put_.keys()
['FullScreen', 'Width', 'Silent', 'Resizable', 'Visible',
'RegisterAsBrowser', 'StatusText', 'Top', 'Height', 'RegisterAsDropTarget',
'StatusBar', 'TheaterMode', 'Offline', 'Left', 'AddressBar', 'ToolBar',
'MenuBar']
>>> ie._prop_map_get_.keys()
['ReadyState', 'Busy', 'Container', 'Silent', 'Top', 'RegisterAsDropTarget',
'LocationName', 'Application', 'Offline', 'Document', 'Type', 'ToolBar',
'MenuBar', 'FullScreen', 'Parent', 'TheaterMode', 'Path', 'Name',
'RegisterAsBrowser', 'StatusText', 'Left', 'TopLevelContainer', 'Resizable',
'Width', 'StatusBar', 'HWND', 'Height', 'Visible', 'FullName',
'LocationURL', 'AddressBar']

Clearly there is a 'Height' property for Put and Get.

>>> ie.Height = 600

Actually changes IE's height.

>>> ie.Height
600

Reports it.

But ...

>>> print ie.GetProperty('Height')
None
>>>

And ...

>>> print ie.PutProperty('Height', 400) 
None
>>>

Does nothing.

Any clues how to use the GetProperty and PutProperty methods?

Thanks!

Richard



More information about the Python-win32 mailing list