#Include lib\UIA_Interface.ahk SetTitleMatchMode, 2 global UIA := UIA_Interface() ;learn more here https://github.com/Descolada/UIAutomation/wiki/04.-Elements el := WinExist(" github.com/Descolada/UIAutomation ahk_exe AutoHotkey.exe") el := UI7(el) ; the handle can be re-used for various actions Do_Click7(el) UI7(el){ WinActivate, ahk_id %el% WinWaitActive, ahk_id %el% el := UIA.ElementFromHandle(el) return el } Do_Click7(el){ loop, 10 { try { el := el.FindFirstBy("ControlType=Document AND Name='Start capturing and press the F3 Key to add action.' AND AutomationId='41'",,2) break } catch e{ Sleep, 100 } } loop, 10 { try { el.Click() break } catch e{ Sleep, 100 } } }