AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Interest in getting text under mouse cursor

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List
View previous topic :: View next topic  
Author Message
vashk



Joined: 07 Jan 2008
Posts: 11

PostPosted: Tue Jan 08, 2008 6:18 am    Post subject: Interest in getting text under mouse cursor Reply with quote

First post so I want to start off by saying AHK is a great tool and I've already written several useful scripts in a short time to help with RSI and other annoyances, so thank you Chris.

I'm trying to write a fast translation tool that grabs the text under the mouse and displays a tooltip in the target language*, but I'm missing a couple pieces. The biggest hurdle so far is sneaking the text off any part of the screen without resorting to OCR.

*by target language I mean if the text (based on its UTF-8 values) is in the user's native language it translates to a user-configurable language and if it is in any non-native language it translates to the user's native language

The idea of using MSAA (Microsoft Active Accessibility) has been thrown around, and I already found it on the Planned Features page:

http://www.autohotkey.com/changelog/PendingChanges.htm

I have another suggestion, which is to use a 3rd party DLL by Deskperience. My idea would be to use MouseGetPos command in AHK and pass the resulting coordinates and HWND to the DLL's GetTextFromPoint method.**

**The WordCapture part of the project has been completed using this method. Thanks for the useful suggestions. I'll update when the project is finished in case anyone's interested.
_________________
--v


Last edited by vashk on Fri Jan 11, 2008 2:41 pm; edited 1 time in total
Back to top
View user's profile Send private message
majkinetor



Joined: 24 May 2006
Posts: 3593
Location: Belgrade

PostPosted: Tue Jan 08, 2008 11:58 am    Post subject: Reply with quote

Check out Active Accesibilty COM module.
_________________
Back to top
View user's profile Send private message MSN Messenger
vashk



Joined: 07 Jan 2008
Posts: 11

PostPosted: Tue Jan 08, 2008 6:18 pm    Post subject: Reply with quote

Thanks majkinetor...

Do you have a link for this Active Accessibility COM module? I tried searching the forums and AHK script sites but all I could find was this topic:

http://www.autohotkey.com/forum/topic21808.html&highlight=active+accessibility+com

I'll certainly be reading it in more detail.
I appreciate your help.

Edit:

If you mean Microsoft Active Accessibility itself, I'm already looking at that, as indicated in my first post. I modified the code Sean posted in the above topic to find everything MSAA could tell me about a control (using mouse hover and logging to file the results) and it's a step up from ControlGet, but it still doesn't provide enough information about what visible text actually is under the mouse.
_________________
--v
Back to top
View user's profile Send private message
Guest






PostPosted: Wed Jan 09, 2008 11:36 am    Post subject: Reply with quote

http://www.autohotkey.com/forum/topic24234.html&highlight=accessibility+com
Back to top
vashk



Joined: 07 Jan 2008
Posts: 11

PostPosted: Wed Jan 09, 2008 4:50 pm    Post subject: Reply with quote

Thanks for the link. It turns out MSAA does not have the single-word granularity I'm looking for. I was able to write an AHK script using the 3rd party DLL I discussed previously which captures words from any part of the screen. I think it might be non-commercially distributable. Here's hoping for a free tool that can be distributed with a future version of AHK.

For anyone who's interested here's the code... it's really just a proof-of-concept.

Code:
;----Aqua Deskperience----
;Version 1.3
;System requirements:
;Windows 2000, Windows XP, Windows 2003 Server
;Internet Explorer 5.5+
;400MHz processor
;128MB RAM
;5 MB of hard-disk space

;------TCaptureX.dll------
;CLSID      : {13FE2FA1-EE8B-45B9-BBB4-08E5F2F43AC3}
;Text       : TextCaptureX Class
;Type       : InProcServer32
;Type Value : C:\Program Files\Deskperience\Aqua\TCaptureX.dll
;ProgID     : TCaptureX.TextCaptureX.1
;TypeLib    : {92657C70-D31B-4930-9014-379E3F6FB91A}

wordCapture()
;returns the word under the mouse
;requires TCaptureX.dll from Aqua Deskperience
;requires COM AHK library
{
    CoordMode Mouse, Screen ;sets Mouse mode to global coordinates
    MouseGetPos mX, mY, w_hWnd, c_hWnd, 2
    COM_CoInitialize()
    hModule := DllCall("LoadLibrary","str","TCaptureX.dll")
    suuid := "{13FE2FA1-EE8B-45B9-BBB4-08E5F2F43AC3}"
    pTcx := COM_CreateObject(suuid)
    ;guid is alias for CLSID_TextCaptureX
    ;guid := COM_GUID4String(CLSID_TextCaptureX,suuid)

    ;GetTextFromPoint requires (x,y) position in global coordinates
    ;GetTextFromPoint also requires handle to the parent window of text
    text := COM_Invoke(pTcx,"GetTextFromPoint",w_hWnd,mX,mY)
   
    COM_Release(pTcx)
    DllCall("FreeLibrary", "UInt", hModule)
    COM_CoUninitialize()
    return text
}

_________________
--v
Back to top
View user's profile Send private message
Sakurako



Joined: 10 May 2007
Posts: 142

PostPosted: Thu Jan 17, 2008 10:09 pm    Post subject: Reply with quote

Why not just use language code? ~

Link: http://www.autohotkey.com/docs/misc/Languages.htm
Back to top
View user's profile Send private message
vashk



Joined: 07 Jan 2008
Posts: 11

PostPosted: Fri Jan 18, 2008 3:50 am    Post subject: Reply with quote

Sakurako wrote:
Why not just use language code? ~

Link: http://www.autohotkey.com/docs/misc/Languages.htm


Yes, I am using language code to determine the user's native language, but that's only a small part of the code.
_________________
--v
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group