获取Windows中的鼠标光标下的单词 [英] Get the word under the mouse cursor in Windows

查看:600
本文介绍了获取Windows中的鼠标光标下的单词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问候大家,

我和一个朋友正在讨论一个新项目的可能性:一个翻译程序,只要你将鼠标悬停在任何文字中的任何控制,即使是静态的,不可编辑的那些会弹出一个翻译。我知道有很多浏览器插件做这样的网页上的东西;我们正在考虑,我们会怎么做系统级(在Windows上)。

A friend and I are discussing the possibility of a new project: A translation program that will pop up a translation whenever you hover over any word in any control, even static, non-editable ones. I know there are many browser plugins to do this sort of thing on webpages; we're thinking about how we would do it system-wide (on Windows).

当然,关键的难点是搞清楚用户悬停在词。我知道MSAA和自动化的,但据我所知,那些东西只能让你得到控制,而不是特定的词鼠标悬停的全部内容。

Of course, the key difficulty is figuring out the word the user is hovering over. I'm aware of MSAA and Automation, but as far as I can tell, those things only allow you to get the entire contents of a control, not the specific word the mouse is over.

我偶然发现了这个(专有)的应用程序,做pretty很多正是我们想做的事:的http:/ /www.gettranslateit.com/

I stumbled upon this (proprietary) application that does pretty much exactly what we want to do: http://www.gettranslateit.com/

不知怎的,他们都能够得到确切的词,用户悬停在几乎任何应用程序(它似乎有一些应用程序,特别是Windows资源管理器的麻烦)。它甚至抓住了文字显然自定义绘制控件,不知何故。起初我以为它必须使用OCR。但是,即使当我缩小字体到目前为止下来文本成为一个完全不可读的blob,它仍然可以识别的词完美。 (然而,它不,如果我改变字体为宋体承认什么。但也许这是设计?)

Somehow they are able to get the exact word the user is hovering over in almost any application (It seems to have trouble in a few apps, notably Windows Explorer). It even grabs text out of obviously custom-drawn controls, somehow. At first I thought it must be using OCR. But even when I shrink the font so far down that the text becomes a completely unreadable blob, it can still recognize words perfectly. (And yet, it doesn't recognize anything if I change the font to Wingdings. But maybe that's by design?)

任何想法,它是如何实现这个看似不可能完成的任务?

Any ideas as to how it's achieving this seemingly impossible task?

编辑:它不与宋体工作,但它与其他一些废话字体,所以我已经证实了它不可能是OCR

It doesn't work with Wingdings, but it does work with some other nonsense fonts, so I've confirmed it can't be OCR.

推荐答案

您可以捕捉到GDI调用输出文本到显示器,然后找出哪些字的边框光标落在

You could capture the GDI calls that output text to the display, and then figure out which word's bounding box the cursor falls in.

这篇关于获取Windows中的鼠标光标下的单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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