
#include "UIA_Functions.au3"

Opt("WinTitleMatchMode", 2)

Global $ROPEXTitle = WinGetTitle("ROPEXvisual",'')
Global $oUIAutomation, $pDesktop, $pCondition, $pROPEXe, $pCondition1, $pAndCondition, $pCondition2, $pKlickButton, $pValue

; Find Desktop
$oUIAutomation = ObjCreateInterface($sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation)
$oUIAutomation.GetRootElement($pDesktop)
$oDesktop = ObjCreateInterface($pDesktop, $sIID_IUIAutomationElement, $dtagIUIAutomationElement)

; Find Main Window
$oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, $ROPEXTitle, $pCondition ) ; Window Title
$oDesktop.FindFirst($TreeScope_Descendants, $pCondition, $pROPEXe)
$oROPEXe_Main = ObjCreateInterface($pROPEXe, $sIID_IUIAutomationElement, $dtagIUIAutomationElement)

; Click button
$oUIAutomation.CreatePropertyCondition($UIA_ControlTypePropertyId, $UIA_TabItemControlTypeId, $pCondition1) ; Klick Button $UIA_ControlTypePropertyId   $UIA_ButtonControlTypeId
$oUIAutomation.CreatePropertyCondition($UIA_NamePropertyId, "Settings", $pCondition2) ; Name des Klick-Buttons als 2. Condition   $UIA_NamePropertyId
$oUIAutomation.CreateAndCondition($pCondition1, $pCondition2, $pAndCondition)
$oROPEXe_Main.FindFirst($TreeScope_Descendants, $pAndCondition, $pKlickButton)
$oKlickButton = ObjCreateInterface($pKlickButton, $sIID_IUIAutomationElement, $dtagIUIAutomationElement)
$oKlickButton.GetCurrentPattern($UIA_ValuePatternId, $pValue)
WinActivate($ROPEXTitle)
UIA_MouseClick($oKlickButton)

$oUIAutomation.CreatePropertyCondition($UIA_ControlTypePropertyId, $UIA_ButtonControlTypeId, $pCondition1) ; Klick Button $UIA_ControlTypePropertyId   $UIA_ButtonControlTypeId
$oUIAutomation.CreatePropertyCondition($UIA_NamePropertyId, "Language", $pCondition2) ; Name des Klick-Buttons als 2. Condition   $UIA_NamePropertyId
$oUIAutomation.CreateAndCondition($pCondition1, $pCondition2, $pAndCondition)
$oROPEXe_Main.FindFirst($TreeScope_Descendants, $pAndCondition, $pKlickButton)
$oKlickButton = ObjCreateInterface($pKlickButton, $sIID_IUIAutomationElement, $dtagIUIAutomationElement)
$oKlickButton.GetCurrentPattern($UIA_ValuePatternId, $pValue)
WinActivate($ROPEXTitle)
UIA_MouseClick($oKlickButton)

