It's difficult to do more than one action in a row with the macro creator. For example, if I want to click in this UIAViewer the "Macro creator" tab and then "Case sensitive" checkbox, in the old UIAViewer I first hovered the "Macro creator", pressed PrintScreen, then hovered "Case sensitive" checkbox and pressed PrintScreen, to get the following code:
; #Include <UIA_Interface>
; SetTitleMatchMode, 2
el := WinExist("UIAViewer ahk_exe AutoHotkey.exe ahk_class AutoHotkeyGUI")
WinActivate, ahk_id %el%
WinWaitActive, ahk_id %el%
el := UIA.ElementFromHandle(el)
el.WaitElementExist("ControlType=TabItem AND Name='Macro creator'").Click()
el.WaitElementExist("ControlType=CheckBox AND Name='Case sensitive' AND AutomationId='33'").Click()3'").Click()
With this version I can easily do the first step and get
#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 := UI(el)
; the handle can be re-used for various actions
Do_Click(el)
UI(el){
WinActivate, ahk_id %el%
WinWaitActive, ahk_id %el%
el := UIA.ElementFromHandle(el)
return el
}
Do_Click(el){
loop, 10
{
try {
el := el.FindFirstBy("ControlType=TabItem AND Name='Macro creator'",,2)
break
} catch e{
Sleep, 100
}
}
loop, 10
{
try {
el.Click()
break
} catch e{
Sleep, 100
}
}
}
After that, it isn't very obvious how to do the next click, because F3 gets me this code:
#Include lib\UIA_Interface.ahk
SetTitleMatchMode, 2
global UIA := UIA_Interface()
;learn more here https://github.com/Descolada/UIAutomation/wiki/04.-Elements
el2 := WinExist(" github.com/Descolada/UIAutomation ahk_exe AutoHotkey.exe")
el2 := UI2(el2)
; the handle can be re-used for various actions
Do_Click2(el2)
UI2(el2){
WinActivate, ahk_id %el2%
WinWaitActive, ahk_id %el2%
el2 := UIA.ElementFromHandle(el2)
return el2
}
Do_Click2(el2){
loop, 10
{
try {
el2 := el2.FindFirstBy("ControlType=CheckBox AND Name='Case sensitive' AND AutomationId='31'",,2)
break
} catch e{
Sleep, 100
}
}
loop, 10
{
try {
el2.Click()
break
} catch e{
Sleep, 100
}
}
}
Should I combine them somehow in my own script? How do I do that exactly?
If I add everything starting from el2 := WinExist(" github.com/Descolada/UIAutomation ahk_exe AutoHotkey.exe") I get a script that is 83 lines long to click 2 elements - seems very excessive...
It's difficult to do more than one action in a row with the macro creator. For example, if I want to click in this UIAViewer the "Macro creator" tab and then "Case sensitive" checkbox, in the old UIAViewer I first hovered the "Macro creator", pressed PrintScreen, then hovered "Case sensitive" checkbox and pressed PrintScreen, to get the following code:
With this version I can easily do the first step and get
After that, it isn't very obvious how to do the next click, because F3 gets me this code:
Should I combine them somehow in my own script? How do I do that exactly? If I add everything starting from
el2 := WinExist(" github.com/Descolada/UIAutomation ahk_exe AutoHotkey.exe")
I get a script that is 83 lines long to click 2 elements - seems very excessive...