I am using White
to get a Microsoft Word Window and the Document as a TextBox like this:
Application a = Application.Attach(0x0000AC34);
Window w = a.GetWindow("Document1 - Word", InitializeOption.WithCache);
TextBox doc = w.Get<TextBox>(SearchCriteria.ByControlType(ControlType.Document));
Is there a way to get the position of the caret? I am interested in both, the screen coordinates and the position within the text.
Ideally, I am looking for something in White
.
If not, I know I can rely on AutomationElement
and TextPattern
ie.
TextPattern tp = doc.AutomationElement.GetCurrentPattern(TextPattern.Pattern) as TextPattern;
TextPatternRange[] selectionRanges = tp.GetSelection();
// etc...
Is there any drawbacks in doing so? Are there better options I should consider?
Is there a way I can access the IUIAutomationTextPattern2
interface?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.