-
I'm building an application that opens a small window next to caret, and so I need to find a position of the caret. In some applications, using None of these seem to be working for Terminal. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
I have a progress. I'm able to get a (the code assumes that terminal has focus) var automation = new CUIAutomation();
var element = automation.GetFocusedElement();
var pattern = (IUIAutomationTextPattern)element.GetCurrentPattern(10014);
if (pattern != null)
{
var selectons = pattern.GetSelection();
if (selectons.Length > 0)
{
var selection = selectons.GetElement(0);
var bounds = selection.GetBoundingRectangles();
// bounds is an empty array 👈
}
} Is this a good path? Should it work? Or am I missing something? |
Beta Was this translation helpful? Give feedback.
-
To summarise what we've established in the other threads:
|
Beta Was this translation helpful? Give feedback.
To summarise what we've established in the other threads:
IUIAutomationTextPattern2
, but theGetSelection
method fromIUIAutomationTextPattern
should return the caret position when nothing else is selected.ExpandToEnclosingUnit
to normalize the range to one character unit.GetBoundingRectangles
to obtain the boundaries, and that should give you the position you're looking for.