Update. After more troubleshooting i found a combo-box items only generate it's list after it has been opened. A workaround for this is the code below which opens / closes the combo but doesn't take focus.
; --- Find window/control ---
ConsoleWrite( "--- Find window/control ---" & @CRLF )
Local $pCondition0
$oUIAutomation.CreatePropertyCondition( $UIA_AutomationIdPropertyId, "cmbAddressType", $pCondition0 )
If Not $pCondition0 Then Return ConsoleWrite( "$pCondition0 ERR" & @CRLF )
ConsoleWrite( "$pCondition0 OK" & @CRLF )
Local $pComboBox1, $oComboBox1
$oWindow1.FindFirst( $TreeScope_Descendants, $pCondition0, $pComboBox1 )
$oComboBox1 = ObjCreateInterface( $pComboBox1, $sIID_IUIAutomationElement, $dtagIUIAutomationElement )
If Not IsObj( $oComboBox1 ) Then Return ConsoleWrite( "$oComboBox1 ERR" & @CRLF )
ConsoleWrite( "$oComboBox1 OK" & @CRLF )
Local $pInvoke, $oInvoke
$oComboBox1.GetCurrentPattern( $UIA_LegacyIAccessiblePatternId, $pInvoke)
$oInvoke = ObjCreateInterface( $pInvoke, $sIID_IUIAutomationLegacyIAccessiblePattern, $dtagIUIAutomationLegacyIAccessiblePattern )
If Not IsObj( $oInvoke ) Then Return ConsoleWrite( "$oInvoke ERR" & @CRLF )
ConsoleWrite( "$oInvoke OK" & @CRLF )
$oInvoke.DoDefaultAction()
$oInvoke.DoDefaultAction()
I also found using the Legacy Select lets me select my item without taking focus. I don't know why it needed the number 3 but without it didn't work ^^.
;Find List Item
Local $pCondition4
$oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, "Do it later", $pCondition4 )
If Not $pCondition4 Then Return ConsoleWrite( "$pCondition4 ERR" & @CRLF )
ConsoleWrite( "$pCondition4 OK" & @CRLF )
Local $pListItem1, $oListItem1
$oComboBox1.FindFirst( $TreeScope_Children, $pCondition4, $pListItem1 )
$oListItem1 = ObjCreateInterface( $pListItem1, $sIID_IUIAutomationElement, $dtagIUIAutomationElement )
If Not IsObj( $oListItem1 ) Then Return ConsoleWrite( "$oListItem1 ERR" & @CRLF )
ConsoleWrite( "$oListItem1 OK" & @CRLF )
Local $pInvoke, $oInvoke
$oListItem1.GetCurrentPattern( $UIA_LegacyIAccessiblePatternId, $pInvoke)
$oInvoke = ObjCreateInterface( $pInvoke, $sIID_IUIAutomationLegacyIAccessiblePattern, $dtagIUIAutomationLegacyIAccessiblePattern )
If Not IsObj( $oInvoke ) Then Return ConsoleWrite( "$oInvoke ERR" & @CRLF )
ConsoleWrite( "$oInvoke OK" & @CRLF )
$oInvoke.Select(3)
One random question! Can IUI enable/disable controls similar to ControlEnable/ControlDisable?