tags:

views:

133

answers:

1

Hi there, is there any idea for getting the text under the mouse cursor?

I'm trying to build a dictionary app, that pops up a panel of translates when mouse hangs over a word.

I took a look at the accessiblity apis, and it only can find the current ui element, but not the current word...

my last choice will be makeing screenshots frequently, and doing ocr... that'll be cpu consuming, I don't like that..

any idea for this? thanks in advance!

A: 

While it is possible to do this via supported mechanisms (Spell Catcher X does), it's very hard to get right across a wide range of applications. Take a look at the page on Direct Correct—there are 3 mechanisms supported, none of which work perfectly, etc. etc.

Apple's Dictionary app already supports this kind of pop-up dictionary lookup, which works in many applications. You can create custom dictionaries for it, if you just need word-by-word translation (for example, Apple includes a Japanese-English dictionary). You can reorder reference sources in Dictionary's Preferences to put your dictionary first, if you want.

Otherwise, I'd suggest the OCR route. You don't need to take screenshots frequently, just when the user requests translation, right?

Nicholas Riley
Thanks Nicholas :)Apple's Dictionary app works fine for some cocoa apps like safari/terminal, however it's not working in chrome and firefox.see this: http://www.mail-archive.com/[email protected]/msg73509.htmlso I'm trying to make an app that will use the mechanisms used in Dictionary.app shipped with mac osx when hovers on a cocoa app, and use OCR for those in firefox..so can we hack out how to invoke DictionaryService's "DSGetTextUnderMouse" method? sorry for the newbee questions...
Liuyi Sun
Liuyi Sun: That sounds like a function, not a method, and it is what Dictionary.app uses. If it doesn't work for Dictionary, it won't work for your app, either. See this Chromium bug report: http://code.google.com/p/chromium/issues/detail?id=17951 The Chromium developers are working on the problem from that end.
Peter Hosey