如何取得鼠标位置的文字

unx 2004-06-10 04:44:06
比如鼠标在记事本窗口上,并且在WORD的位置,我怎么得到"word"
我知道可以得到NOTEPAD窗口的文字,但是如果打开的是10M的文件,难道
我还要先复制到内存然后来找?
即使我知道了哪个缓冲区,又怎么知道鼠标指的是哪个字呢
DOS到好办,WINDOWS下突然不知道咋办了
________________________________
|无标题-1 |
--------------------------------
| how to get the word ... |
| $ |
| |
|______________________________|
...全文
183 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
unx 2004-06-18
  • 打赏
  • 举报
回复
thank jiangsheng first
蒋晟 2004-06-14
  • 打赏
  • 举报
回复
Enabling Your Wish and the Needs of Others, Too
Dear Dr. GUI,
How can I grab the text that lies beneath the cursor, independent of the application that the text occurs in?

I am using Visual C++, and, ideally, I would like functionality similar to that found in VC's debugger: When the cursor is placed over a variable, information relevant to the variable is displayed in a box after a short delay, rather like a tool tip.

I have seen translation software give an immediate translation of the word under the cursor, irrespective of the application in which the word resides. How are they doing it? Is it done by using Optical Character Recognition (OCR)? Or is there a more elegant method using the Win32 API?

Thanks in advance,

Henry Brighton

Dr. GUI replies:
Wow, Henry. This turns out to be really interesting because currently there is no single Microsoft Win32® API to get the text underneath the cursor for all Windows-based applications. However, you can get this information for most Windows applications by using the Microsoft Active Accessibility Software Development Kit (SDK).

This technology has been developed by Microsoft for people who have accessibility problems that affect their ability to utilize the standard computer. There are now accessibility aids such as screen review utilities, on-screen keyboard utilities, and so forth. Is this cool or what?

Active Accessibility is based on the Component Object Model (COM) and can be used to obtain or provide information about the system-provided UI elements of Windows applications and the operating system. Currently, it is fully supported on Windows 95, Windows 98, and Windows 2000, and partly supported on Windows NT 4.0 Service Pack 4 and later. The supported UI elements include:

Predefined controls (controls defined in User32.dll), such as list boxes.


Common controls (controls defined in Comctl32.dll), such as toolbars.


Window elements, such as title bars and menus.
Although the UI elements in applications such as Microsoft Office and Visual C++ are supported by this SDK, the Office document content is not.

To obtain more information about the Active Accessibility SDK and where to download its latest version, go to http://www.microsoft.com/enable/msaa/.

快乐鹦鹉 2004-06-14
  • 打赏
  • 举报
回复
这应该有些难度吧。如果是自己做的编辑器还好一点。如果是notepad,文本都不是你控制的。很难获得啊。
lmfweng 2004-06-14
  • 打赏
  • 举报
回复
up

15,473

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 进程/线程/DLL
社区管理员
  • 进程/线程/DLL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧