Thanks for your help.
I just realized that the key to solving the problem lies in the following code.
It seems that many functions in the code are specific to LA, and converting them into generic C# code is too difficult for me.
I would like to convert it into generic C# code and then call it in the filtering function in QM.
I'm not sure if it's possible to implement similar code in QM like LA. If possible, that would be great because when using QM, many controls cannot find the text insertion point.
I just realized that the key to solving the problem lies in the following code.
It seems that many functions in the code are specific to LA, and converting them into generic C# code is too difficult for me.
I would like to convert it into generic C# code and then call it in the filtering function in QM.
internal static bool GetCaretRectInPowerShell(out RECT r) {
var t = ElementFocused();
if (t != null && 0 == t.get_CurrentControlType(out var ct) && ct == UiaApi.TypeId.Edit) {
if (0 == Uia.get_RawViewWalker(out var walker)) {
UiaApi.IUIAutomationElement e = null;
while (0 == (e == null ? walker.GetFirstChildElement(t, out e) : walker.GetNextSiblingElement(e, out e)) && e != null) {
//if (0 == e.get_CurrentControlType(out ct)) print.it(ct);
//if (0 == e.get_CurrentAutomationId(out var ai)) print.it(ai);
if (0 == e.get_CurrentAutomationId(out var ai) && ai.Find("Caret", true) >= 0 && 0 == e.get_CurrentControlType(out ct) && ct == UiaApi.TypeId.Custom) {
if (0 == e.get_CurrentBoundingRectangle(out r)) {
return true;
}
}
}
//There are 3 child elements. The first is caret.
//This is slow. Tested MSAA, but it gets only child element "selection", and cannot get rect when selection empty.
}
}
r = default;
return false;
}
I'm not sure if it's possible to implement similar code in QM like LA. If possible, that would be great because when using QM, many controls cannot find the text insertion point.