C ++ Win32文本选择检测以及在另一个应用程序中的获取和修改 [英] c++ win32 text selection detection and fetching and modifying in another application

查看:119
本文介绍了C ++ Win32文本选择检测以及在另一个应用程序中的获取和修改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我见过一个用于帮助盲人的应用程序,它被称为JAWS(用作屏幕阅读器),它可以检测字符串并在MS Office应用程序,记事本,Internet Explorer等许多应用程序中读取字符串。 。等等。是否有可能在其他应用程序中检测文本选择?如何?我认为使用了辅助功能,但我不知道该怎么做!我可以用快捷键替换选择检测。
_我试图找到以下解决方案

I've seen an application used to help the blind, it's called JAWS (it acts as a screen reader) it detects string and reads it in a lot of applications like MS Office applications, notepad, internet explorer.....etc. Is it possible to detect text selection in another application ?? how?i think accessibility is used but i don't know how to to it! i can replace selection detection with hotekey press. _ i tried to find a solution as the following


  1. 获取顶部和已激活的窗口或从鼠标位置获取。

  2. 从鼠标位置获取其子项。

  3. 获取或设置所选文本。

在ms字中,我使用spy ++来检测包含文本的控件,然后获取 Microsoft Word文档。

In ms word i used spy++ to detect the control that contains the text i get "Microsoft Word Document"

推荐答案

没有简单的方法,因为没有单一的一致性从任意应用程序中获取文本(选择或其他方式)的方法。诸如JAWS之类的应用程序通常会使用全部技术,具体取决于应用程序或控件:

There's no easy way to do this, because there's no single consistent way to get at text (selected or otherwise) from an arbitrary applications. Apps such as JAWS usually have a whole battery of techniques they use, depending on the app or control:


  • 用于EDIT和RichEdit控件,各种 EM_消息工作。

对于Internet Explorer, HTML DOM 可以使用。

For Internet Explorer, the HTML DOM can be used.

对于Word,< HREF = http://en.wikipedia.org/wiki/Text_Object_Model rel = noreferrer>文本对象模型接口可用于访问文本和格式。其他应用程序可能支持类似的特定于应用程序的模型。

For Word, the Text Object Model interfaces can be used to access text and formatting. Other apps may support similar app-specific models.

一些(但不是全部)应用程序和应用程序框架支持可访问性API,例如 UIAutomation IAccessible2 ,它允许访问有关应用程序中控件的信息以及有关文本和文本选择的信息。

Some (but not all) apps and app frameworks support Accessibility APIs such as UIAutomation or IAccessible2, which allows access to information about the controls in the app, and also information about text and text selection.

对于不支持上述任何一项的应用,屏幕阅读器通常使用一种称为屏幕外模型,一种复杂的技术,涉及拦截所有图形输出调用,并维护在何处绘制的内容的内存数据库,以便他们可以查找应在其处显示的文本屏幕上的任何点。

For apps that don't support any of the above, Screenreaders often use a technique called an Off-screen model, a complex technique that involves intercepting all graphical output calls, and maintaining an in-memory database of what was drawn where, so they can look up the text that should be at any point on the screen.

因为这些都不是屏幕阅读器本身涵盖了所有内容,因此屏幕阅读器通常会针对当前应用尝试所有适合的应用:您几乎可以将屏幕阅读器视为是特殊情况代码库,可以从各种应用中提取信息。

Since none of these covers everything in its own right, screenreaders typically try all of them as appropriate for the current app: you can almost think of a screenreader as being a library of special-case code to extract information from various apps.

这篇关于C ++ Win32文本选择检测以及在另一个应用程序中的获取和修改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆