Skip to content

Is there a way to get caret position? #14664

Answered by j4james
maraf asked this question in Q&A
Discussion options

You must be logged in to vote

To summarise what we've established in the other threads:

  1. Windows Terminal doesn't support IUIAutomationTextPattern2, but the GetSelection method from IUIAutomationTextPattern should return the caret position when nothing else is selected.
  2. However, that returned selection will have a zero width, so you'll then need to call ExpandToEnclosingUnit to normalize the range to one character unit.
  3. Once the range has a non-zero width, you can call GetBoundingRectangles to obtain the boundaries, and that should give you the position you're looking for.

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@j4james
Comment options

j4james Jan 12, 2023
Collaborator

@maraf
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by maraf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants