c# - 使用 TestStack.White 获取插入符号位置
问题描述
我正在使用White
这样的文本框来获取 Microsoft Word 窗口和文档:
Application a = Application.Attach(0x0000AC34);
Window w = a.GetWindow("Document1 - Word", InitializeOption.WithCache);
TextBox doc = w.Get<TextBox>(SearchCriteria.ByControlType(ControlType.Document));
有没有办法获得插入符号的位置?我对屏幕坐标和文本中的位置都感兴趣。
理想情况下,我正在寻找White
.
如果没有,我知道我可以依靠AutomationElement
和TextPattern
即。
TextPattern tp = doc.AutomationElement.GetCurrentPattern(TextPattern.Pattern) as TextPattern;
TextPatternRange[] selectionRanges = tp.GetSelection();
// etc...
这样做有什么缺点吗?我应该考虑更好的选择吗?
有没有办法可以访问IUIAutomationTextPattern2
界面?
解决方案
推荐阅读
- c++ - 通过 ROS 网络发送激光雷达数据时的 std::bad_alloc
- angularjs - Angular Schematics - 在树上应用数以千计的更改导致错误超出最大调用堆栈大小
- r - 在R中读取多个带有时间戳的csv文件
- snowflake-cloud-data-platform - 如何在 Pypika 中“最少”使用雪花?
- angular - matdialog 在某个时间尝试弹出时显示为空
- java - 404 状态和 url 模式的 Spring 控制器异常处理
- mysql - MySQL 类似枢轴的操作,以获取每种事件类型每天总事件百分比的细分
- c - 使用 C 打印系统时间时出现意外输出
- python - 为什么此代码返回“pop index out of range”?
- reactjs - 如何使用 typescript 在 React 中动态创建 JSX 标签?