Jump to content

Recommended Posts

Posted

Hello, I'm using UIA wrappers to find elements. This is the minimal example:

#include "UIAWrappers.au3"

; ....


Local $arr[2], $pCondition, $orCondition
$UIA_oUIAutomation.createPropertyCondition($UIA_AutomationIdPropertyId, $ids[0], $pCondition)
$arr[0] = ObjCreateInterface($pCondition, $sIID_IUIAutomationPropertyCondition, $dtagIUIAutomationPropertyCondition)
$UIA_oUIAutomation.createPropertyCondition($UIA_AutomationIdPropertyId, $ids[1], $pCondition)
$arr[1] = ObjCreateInterface($pCondition, $sIID_IUIAutomationPropertyCondition, $dtagIUIAutomationPropertyCondition)
Local $res = $UIA_oUIAutomation.CreateOrConditionFromNativeArray($arr, 2,  $orCondition)
ConsoleWrite(Hex($res))

I'm trying to pass array as an parameter to createOrConditionFromNativeArray, but $res (HRESULT) returns this error code:

0x80004003    E_POINTER Pointer that is not valid

 

By documentation, CreateOrConditionFromNativeArray takes pointer to the array. 

The question is - should I convert it somehow so I can pass it to IUIAutomation object? Or is there some other issue?

 

Note: There is CreateOrCondition method, which works fine with $arr[0] and $arr[1] references. It does not work only with array version.

 

Posted

I think that a native array means a C-type array. You create C-type arrays with DllStruct functions. Something like this (untested):

$tCArray = DllStructCreate( "ptr[2]" )
DllStructSetData( $tCArray, 1, $pCondition1, 1 )
DllStructSetData( $tCArray, 1, $pCondition2, 2 )
$res = $UIA_oUIAutomation.CreateOrConditionFromNativeArray(DllStructGetPtr( $tCArray ), 2, $orCondition)

Note that this is not .NET functions. This is Windows API functions: Overview docu, Reference docu

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...