Reading word at mouse pointer w/o Universal Access

  • I've read this post (http://lists.apple.com/archives/accessibility-dev/2006/Aug/msg00007.html
    ) about using the accessibility options to read the text under the
    cursor. However, this requires that the user enable access for
    assistive devices in System Preferences. The application must
    therefore check for that. It also seems quite complicated; I don't
    want to have to deal with glyphs and the like - I only want the text
    under the cursor, full stop.

    The Dictionary application is able to read a word under the cursor
    without enabling access for assistive devices.

    Does anyone therefore know of an alternative way to do this?

    Thanks in advance.
  • Let me clarify that it doesn't seem to be the Dictionary application
    that's reading the word at the mouse pointer but rather the OS itself
    or some daemon, perhaps, when  Ctrl-Option-D is pressed. It might be
    the process called DictionaryPanel that seems to always be running.

    Anyway, if anyone can point me to the appropriate functions/methods/
    classes that might be involved in doing such a thing w/o the
    aforementioned techniques, please let me know.

    On 28-Feb-08, at 8:27 PM, Ryan Homer wrote:

    > I've read this post (http://lists.apple.com/archives/accessibility-dev/2006/Aug/msg00007.html
    > ) about using the accessibility options to read the text under the
    > cursor. However, this requires that the user enable access for
    > assistive devices in System Preferences. The application must
    > therefore check for that. It also seems quite complicated; I don't
    > want to have to deal with glyphs and the like - I only want the text
    > under the cursor, full stop.
    >
    > The Dictionary application is able to read a word under the cursor
    > without enabling access for assistive devices.
    >
    > Does anyone therefore know of an alternative way to do this?
    >
    > Thanks in advance.
  • I don't have specific knowledge but, yes, I would expect that the
    dictionary support is a trusted part of the OS, thus can be hooked
    into every application.

    As far as I know, if you want to touch another application's UI, you
    have to go through accessibility. From the OS's point of view yours
    is just another application, so it seems reasonable that the user
    should decide whether or not to allow your application to see what's
    going on in another.

    steve

    On Feb 28, 2008, at 5:33 PM, Ryan Homer wrote:

    > Let me clarify that it doesn't seem to be the Dictionary
    > application that's reading the word at the mouse pointer but rather
    > the OS itself or some daemon, perhaps, when  Ctrl-Option-D is
    > pressed. It might be the process called DictionaryPanel that seems
    > to always be running.
    >
    > Anyway, if anyone can point me to the appropriate functions/methods/
    > classes that might be involved in doing such a thing w/o the
    > aforementioned techniques, please let me know.
    >
    > On 28-Feb-08, at 8:27 PM, Ryan Homer wrote:
    >
    >> I've read this post (http://lists.apple.com/archives/accessibility-
    >> dev/2006/Aug/msg00007.html) about using the accessibility options
    >> to read the text under the cursor. However, this requires that the
    >> user enable access for assistive devices in System Preferences.
    >> The application must therefore check for that. It also seems quite
    >> complicated; I don't want to have to deal with glyphs and the like
    >> - I only want the text under the cursor, full stop.
    >>
    >> The Dictionary application is able to read a word under the cursor
    >> without enabling access for assistive devices.
    >>
    >> Does anyone therefore know of an alternative way to do this?
    >>
    >> Thanks in advance.
  • On Feb 29, 2008, at 02:33, Ryan Homer wrote:

    > Let me clarify that it doesn't seem to be the Dictionary application
    > that's reading the word at the mouse pointer but rather the OS
    > itself or some daemon, perhaps, when  Ctrl-Option-D is pressed. It
    > might be the process called DictionaryPanel that seems to always be
    > running.
    >
    > Anyway, if anyone can point me to the appropriate functions/methods/
    > classes that might be involved in doing such a thing w/o the
    > aforementioned techniques, please let me know.

    Maybe you're looking for services? They're right in the application
    menu. They can do a lot of very nifty things, unfortunately they're
    very under-appreciated since they got moved one level down...

    andy
  • Well, if you are referring to the Services sub-menu that is
    automatically part of Cocoa applications' menus with the same name as
    the application (Eg: Mail -> Services, Safari -> Services, etc.), it
    seems to me that those services are only executed when invoked by the
    user. However, I want my application to be able to react to just the
    mouse pointer moving over a word.

    On 28-Feb-08, at 9:27 PM, Andreas Monitzer wrote:

    > On Feb 29, 2008, at 02:33, Ryan Homer wrote:
    >
    >> Let me clarify that it doesn't seem to be the Dictionary
    >> application that's reading the word at the mouse pointer but rather
    >> the OS itself or some daemon, perhaps, when  Ctrl-Option-D is
    >> pressed. It might be the process called DictionaryPanel that seems
    >> to always be running.
    >>
    >> Anyway, if anyone can point me to the appropriate functions/methods/
    >> classes that might be involved in doing such a thing w/o the
    >> aforementioned techniques, please let me know.
    >
    > Maybe you're looking for services? They're right in the application
    > menu. They can do a lot of very nifty things, unfortunately they're
    > very under-appreciated since they got moved one level down...
    >
    > andy
  • Steve,

    While I agree that the user should decide whether or not to allow the
    application to access another's text, to me, that's exactly what they
    are doing if they decide to use the application. It is going to be a
    dictionary-type application, so if the user installs it, s/he would be
    fully aware that its use would entail moving the mouse pointer over a
    word in another application. The application would be just about
    useless without that feature - so might as well delete it if you don't
    want that feature. It's just that I don't want to require that the
    user have to enable access for assistive devices. The first time I
    came across that, I was hesitant to enable that without knowing more
    about it and how many more services I would be keeping running all the
    time in the background, etc. This made me hesitant to even use the
    application that wanted to turn this on.

    On 28-Feb-08, at 8:59 PM, Steve Christensen wrote:

    > I don't have specific knowledge but, yes, I would expect that the
    > dictionary support is a trusted part of the OS, thus can be hooked
    > into every application.
    >
    > As far as I know, if you want to touch another application's UI, you
    > have to go through accessibility. From the OS's point of view yours
    > is just another application, so it seems reasonable that the user
    > should decide whether or not to allow your application to see what's
    > going on in another.
    >
    > steve
    >
    >
    > On Feb 28, 2008, at 5:33 PM, Ryan Homer wrote:
    >
    >> Let me clarify that it doesn't seem to be the Dictionary
    >> application that's reading the word at the mouse pointer but rather
    >> the OS itself or some daemon, perhaps, when  Ctrl-Option-D is
    >> pressed. It might be the process called DictionaryPanel that seems
    >> to always be running.
    >>
    >> Anyway, if anyone can point me to the appropriate functions/methods/
    >> classes that might be involved in doing such a thing w/o the
    >> aforementioned techniques, please let me know.
    >>
    >> On 28-Feb-08, at 8:27 PM, Ryan Homer wrote:
    >>
    >>> I've read this post (http://lists.apple.com/archives/accessibility-dev/2006/Aug/msg00007.html
    >>> ) about using the accessibility options to read the text under the
    >>> cursor. However, this requires that the user enable access for
    >>> assistive devices in System Preferences. The application must
    >>> therefore check for that. It also seems quite complicated; I don't
    >>> want to have to deal with glyphs and the like - I only want the
    >>> text under the cursor, full stop.
    >>>
    >>> The Dictionary application is able to read a word under the cursor
    >>> without enabling access for assistive devices.
    >>>
    >>> Does anyone therefore know of an alternative way to do this?
    >>>
    >>> Thanks in advance.

  • Just so you know, the Accessibility API has AXMakeProcessTrusted(),
    which will enable access to the API for just your application. It
    requires that it be called from a process running as root, so the user
    needs to enter his/her password, but otherwise it is fully automatic.

    I blogged about it a while ago here: http://caffeinatedcocoa.com/blog/?p=12
    There is also some sample code included.

    Adam Leonard

    On Mar 2, 2008, at 6:24 AM, Ryan Homer wrote:

    > Steve,
    >
    > While I agree that the user should decide whether or not to allow
    > the application to access another's text, to me, that's exactly what
    > they are doing if they decide to use the application. It is going to
    > be a dictionary-type application, so if the user installs it, s/he
    > would be fully aware that its use would entail moving the mouse
    > pointer over a word in another application. The application would be
    > just about useless without that feature - so might as well delete it
    > if you don't want that feature. It's just that I don't want to
    > require that the user have to enable access for assistive devices.
    > The first time I came across that, I was hesitant to enable that
    > without knowing more about it and how many more services I would be
    > keeping running all the time in the background, etc. This made me
    > hesitant to even use the application that wanted to turn this on.
    >
    > On 28-Feb-08, at 8:59 PM, Steve Christensen wrote:
    >
    >> I don't have specific knowledge but, yes, I would expect that the
    >> dictionary support is a trusted part of the OS, thus can be hooked
    >> into every application.
    >>
    >> As far as I know, if you want to touch another application's UI,
    >> you have to go through accessibility. From the OS's point of view
    >> yours is just another application, so it seems reasonable that the
    >> user should decide whether or not to allow your application to see
    >> what's going on in another.
    >>
    >> steve
    >>
    >>
    >> On Feb 28, 2008, at 5:33 PM, Ryan Homer wrote:
    >>
    >>> Let me clarify that it doesn't seem to be the Dictionary
    >>> application that's reading the word at the mouse pointer but
    >>> rather the OS itself or some daemon, perhaps, when  Ctrl-Option-D
    >>> is pressed. It might be the process called DictionaryPanel that
    >>> seems to always be running.
    >>>
    >>> Anyway, if anyone can point me to the appropriate functions/
    >>> methods/classes that might be involved in doing such a thing w/o
    >>> the aforementioned techniques, please let me know.
    >>>
    >>> On 28-Feb-08, at 8:27 PM, Ryan Homer wrote:
    >>>
    >>>> I've read this post (http://lists.apple.com/archives/accessibility-dev/2006/Aug/msg00007.html
    >>>> ) about using the accessibility options to read the text under
    >>>> the cursor. However, this requires that the user enable access
    >>>> for assistive devices in System Preferences. The application must
    >>>> therefore check for that. It also seems quite complicated; I
    >>>> don't want to have to deal with glyphs and the like - I only want
    >>>> the text under the cursor, full stop.
    >>>>
    >>>> The Dictionary application is able to read a word under the
    >>>> cursor without enabling access for assistive devices.
    >>>>
    >>>> Does anyone therefore know of an alternative way to do this?
    >>>>
    >>>> Thanks in advance.


    >
  • On Feb 29, 2008, at 03:27, Ryan Homer wrote:

    > I've read this post (http://lists.apple.com/archives/accessibility-
    > dev/2006/Aug/msg00007.html) about using the accessibility options
    > to read the text under the cursor. However, this requires that the
    > user enable access for assistive devices in System Preferences. The
    > application must therefore check for that. It also seems quite
    > complicated; I don't want to have to deal with glyphs and the like
    > - I only want the text under the cursor, full stop.
    >
    > The Dictionary application is able to read a word under the cursor
    > without enabling access for assistive devices.
    >
    > Does anyone therefore know of an alternative way to do this?

    You can write a service which let the user to select some text and
    pass it to the service. This will be easy to develop and support, but
    not useful as the built-in dictionary app.

    More risky alternative is an input manager, which let poke into any
    Cocoa app data you like without enabling accessibility. However,
    input managers are deprecated and may stop working at some point in
    the future. Writing input manager is easy, but not well documented.

    For input manager examples, see:

    - http://www.lorax.com/FreeStuff/TextExtras.html - The original input
    manager example code. Show how to watch the first responder which you
    can use to access the text bellow the cursor.
    - http://www.culater.net/software/SIMBL/SIMBL.php - framework for
    loading input managers

    There is related discussion here: <http://switchersblog.com/
    2007/08/31/the-end-of-the-input-manager-and-pimping-mac-os-x.html
    >

    Another more evil alternative is APE <http://www.unsanity.org/> - it
    will let you access any app data.

    Best Regards,

    Nir Soffer
  • On 28/02/08 8:27 PM, "Ryan Homer" <hzc.lists...> wrote:

    > I've read this post
    > (http://lists.apple.com/archives/accessibility-dev/2006/Aug/msg00007.html
    > ) about using the accessibility options to read the text under the
    > cursor. However, this requires that the user enable access for
    > assistive devices in System Preferences. The application must
    > therefore check for that. It also seems quite complicated; I don't
    > want to have to deal with glyphs and the like - I only want the text
    > under the cursor, full stop.
    >
    > The Dictionary application is able to read a word under the cursor
    > without enabling access for assistive devices.
    >
    > Does anyone therefore know of an alternative way to do this?
    >
    > Thanks in advance.
    >

    The Dictionary panel  is a special kind of input method component:

    /System/Library/Components/DictionaryService.component

    It uses various techniques to obtain the text from the application (Text
    Service Manager and TSM Document Access CarbonEvents, along with
    Accessibility APIs).

    If Accessibility is off, and your app isn't a trusted one, TSM (and
    presumably the Leopard IMKit equivalents) is the only reliable way to get
    the text at any screen location. Many apps support this, there are still
    quite a few that don't. There are some that support one, but not the other.
    Best to try TSM first, then if no luck try AX.

    If you take a close look, the Dictionary panel will also try to get the font
    and style information, and display the word(s) being defined with their
    actual attributes. Again, some apps support this via TSM, AX, or even both,
    the majority of apps don't. All the Mac OS X editing views (NSTextView,
    MLTE/HITextView, editable WebKit views) support both - perhaps not
    perfectly, but well enough.

    If your requirements are that this must work anywhere, with any app, forget
    it. Try to get the Dictionary popup to do anything in MS Word, for
    example...

    Hope that helps,
    Evan Gross
    --
    Evan Gross, President, Rainmaker Research Inc.
    Developers of Macintosh and Windows Software
    Spell Catcher for Mac OS and Windows
    http://www.rainmakerinc.com/
previous month february 2008 next month
MTWTFSS
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29    
Go to today