This is my first time posting. I want to first say thank you to the community in particular @jeeswg because I've referred to your helpful posts many times.
I've written some shortcuts using Acc, and they work great. I'd now like to switch to UIA (to futureproof my code, and also to try to make it work in the background; ie on inactive windows).
I'm stuck almost at square 1. I'm trying to access a TreeItem that Acc has no problem finding using a path, but UIA cannot seem to find using its find functions.
The "Profiles" TreeItem is visible in the nppFTP plugin of Notepad++, and is shown in the screenshot below, next to the UIAViewer which shows the Acc path:
The Acc code below works as intended:
Code: Select all
#Include Acc.ahk
^q::
myHwnd:= WinExist("A")
ProfilesPath:= "4.3.4.2.4.1.4.2.4.1"
Profiles:=Acc_Get("Object", ProfilesPath, 0, "ahk_id " myHwnd) ; first profile
name:= Profiles.accName
MsgBox, Profiles name is %name%
Return
However, the UIA code below cannot find the Profiles TreeItem:
Code: Select all
#include UIA_Interface.ahk
^q::
myHwnd:= WinExist("A")
UIA := UIA_Interface() ; Initialize UIA interface
nppEl := UIA.ElementFromHandle(myHwnd) ; Get the element for the Notepad++ window
ProfilesUIA := nppEl.FindFirstByName("Profiles")
name:= ProfilesUIA.name
MsgBox, Profiles name is %name%
Return
Is my UIA code all wrong?
I'd be grateful for any help!