Hi,
I'm trying to use comtypes to work with com based UIAutomation framework.
So far I was able to compile "UIAutomationClient.idl", generate wrapper
module, access "IUIAutomation" interface and call some simple methods and
properties.
But I have problems with "CreatePropertyCondition" and
"CreatePropertyConditionEx" methods.
For example calling:
IUIAutomation.CreatePropertyCondition(UIAutomationClient.UIA_ClassNamePropertyId,
('Window'))
throw warning:
Exception WindowsError: 'exception: stack overflow' in <bound method
tagVARIANT.__del__ of VARIANT(vt=0x8, u'Window')> ignored
and return null pointer to "IUIAutomationCondition"
<POINTER(IUIAutomationCondition) ptr=0x0 at 27a18c8>
using this pointer in IUIAutomationElement.FindFirst() method then throw:
WindowsError: exception: access violation writing 0x0000000000030000
Another symptom is that calling "CreatePropertyCondition" second time,
after first call return uninitialized pointer, throw also access violation
exception:
ctypes.ArgumentError: argument 2: <type 'exceptions.WindowsError'>:
exception: access violation writing 0x0000000000030000
When using "CreatePropertyConditionEx", access violation problem does not
occur. But still, returned pointer point to 0x0 and therefore it can not be
used as argument in further methods.
_ctypes.COMError: (-2147467261, 'Invalid pointer', (None, None, None, 0,
None))
Does anybody know what is wrong and how to fix it.
thanks
jozef
os: Windows 7 Enterprise, Service Pack 1
python: 2.7.4 (default, Apr 6 2013, 19:55:15) [MSC v.1500 64 bit (AMD64)]
comtypes: 0.6.2
IUIAutomation interface:
http://msdn.microsoft.com/en-us/library/windows/desktop/ee671406(v=vs.85).aspx
comtypes generated wrapper:
class
IUIAutomation(comtypes.gen._00020430_0000_0000_C000_000000000046_0_2_0.IUnknown):
_case_insensitive_ = True
_iid_ = GUID('{30CBE57D-D9D0-452A-AB13-7AC5AC4825EE}')
_idlflags_ = []
IUIAutomation._methods_ = [
...
COMMETHOD([], HRESULT, 'CreatePropertyCondition',
( ['in'], c_int, 'propertyId' ),
( ['in'], VARIANT, 'value' ),
( ['retval', 'out'],
POINTER(POINTER(IUIAutomationCondition)), 'newCondition' )),
COMMETHOD([], HRESULT, 'CreatePropertyConditionEx',
( ['in'], c_int, 'propertyId' ),
( ['in'], VARIANT, 'value' ),
( ['in'], PropertyConditionFlags, 'flags' ),
( ['retval', 'out'],
POINTER(POINTER(IUIAutomationCondition)), 'newCondition' )),
...
example:
from comtypes.client import CreateObject, GetModule
UIAutomationClient = GetModule(r'c:\Work\Temp\UIAutomationClient.tlb')
IUIAutomation = CreateObject("{ff48dba4-60ef-4201-aa87-54103eef594e}",
interface=UIAutomationClient.IUIAutomation)
### this works
root = IUIAutomation.GetRootElement()
print root
print root.CurrentClassName
print root.CurrentControlType
### this produce uninitialized pointer and throw access violation exception
#cnd1 =
IUIAutomation.CreatePropertyCondition(UIAutomationClient.UIA_ClassNamePropertyId,
'Window')
#print cnd1
#
#cnd2 =
IUIAutomation.CreatePropertyCondition(UIAutomationClient.UIA_IsKeyboardFocusablePropertyId,
True)
#print cnd2
### this produce uninitialized pointer
cnd1 =
IUIAutomation.CreatePropertyConditionEx(UIAutomationClient.UIA_ClassNamePropertyId,
'Window',
UIAutomationClient.PropertyConditionFlags_None)
print cnd1
cnd2 =
IUIAutomation.CreatePropertyConditionEx(UIAutomationClient.UIA_IsKeyboardFocusablePropertyId,
True,
UIAutomationClient.PropertyConditionFlags_None)
print cnd2
cnd = IUIAutomation.CreateAndCondition(cnd1, cnd2)
elm = root.FindFirst(UIAutomationClient.TreeScope_Children, cnd)
print elm
------------------------------------------------------------------------------
Get your SQL database under version control now!
Version control is standard for application code, but databases havent
caught up. So what steps can you take to put your SQL databases under
version control? Why should you start doing it? Read more to find out.
http://pubads.g.doubleclick.net/gampad/clk?id=49501711&iu=/4140/ostg.clktrk
_______________________________________________
comtypes-users mailing list
comtypes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/comtypes-users