Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Generate QM code for UIA using Grok3.
#5
QM UIA examples.

Macro UIA example - find by name and click
 
Code:
Copy      Help
int w=win("Edge" "Chrome_WidgetWin_1")
str name="Extensions"
int nameFlags=0 ;;1 case-insensitive, 2 match substring

UIA.CUIAutomation8 uia._create
UIA.IUIAutomationElement ew=uia.ElementFromHandle(+w)
UIA.IUIAutomationCondition pc=uia.CreatePropertyConditionEx(UIA.UIA_NamePropertyId name nameFlags)
UIA.IUIAutomationElement ef=ew.FindFirst(UIA.TreeScope_Descendants pc)
out ef.CurrentName

sub.UiaClick ef


#sub UiaClick
function UIA.IUIAutomationElement&e

UIA.tagPOINT p
if 0!=e.GetClickablePoint(p)
,lef p.x p.y
else
,UIA.tagRECT r=e.CurrentBoundingRectangle
,lef r.left+r.right/2 r.top+r.bottom/2


#sub UiaClickAt
function UIA.IUIAutomationElement&e x y

UIA.tagRECT r=e.CurrentBoundingRectangle
lef r.left+x r.top+y

Macro UIA example - find by description and get parent
 
Code:
Copy      Help
int w=win("Edge" "Chrome_WidgetWin_1")
str desc="Refresh"
int descFlags=2 ;;1 case-insensitive, 2 match substring

UIA.CUIAutomation8 uia._create
UIA.IUIAutomationElement ew=uia.ElementFromHandle(+w)
UIA.IUIAutomationCondition pc=uia.CreatePropertyConditionEx(UIA.UIA_FullDescriptionPropertyId desc descFlags)
UIA.IUIAutomationElement6 ef=+ew.FindFirst(UIA.TreeScope_Descendants pc)
out ef.CurrentFullDescription

UIA.IUIAutomationTreeWalker walk=uia.RawViewWalker
UIA.IUIAutomationElement ep=walk.GetParentElement(+ef)
UIA.tagRECT r=ep.CurrentBoundingRectangle
out F"{r.left} {r.top}"

Macro UIA example - find by type and name
Code:
Copy      Help
int w=win("Edge" "Chrome_WidgetWin_1")
int role=UIA.UIA_ButtonControlTypeId
str name="Extensions"
int nameFlags=0 ;;1 case-insensitive, 2 match substring

UIA.CUIAutomation8 uia._create
UIA.IUIAutomationElement ew=uia.ElementFromHandle(+w)
UIA.IUIAutomationCondition pc=uia.CreateAndCondition(uia.CreatePropertyCondition(UIA.UIA_ControlTypePropertyId role) uia.CreatePropertyConditionEx(UIA.UIA_NamePropertyId name nameFlags))
UIA.IUIAutomationElement ef=ew.FindFirst(UIA.TreeScope_Descendants pc)
out ef.CurrentName


Messages In This Thread
RE: Generate QM code for UIA using Grok3. - by Gintaras - 03-21-2025, 12:58 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)