| View previous topic :: View next topic |
| Author |
Message |
vashk
Joined: 07 Jan 2008 Posts: 11
|
Posted: Tue Jan 08, 2008 6:18 am Post subject: Interest in getting text under mouse cursor |
|
|
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 |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 3593 Location: Belgrade
|
Posted: Tue Jan 08, 2008 11:58 am Post subject: |
|
|
Check out Active Accesibilty COM module. _________________
 |
|
| Back to top |
|
 |
vashk
Joined: 07 Jan 2008 Posts: 11
|
Posted: Tue Jan 08, 2008 6:18 pm Post subject: |
|
|
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 |
|
 |
Guest
|
|
| Back to top |
|
 |
vashk
Joined: 07 Jan 2008 Posts: 11
|
Posted: Wed Jan 09, 2008 4:50 pm Post subject: |
|
|
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 |
|
 |
Sakurako
Joined: 10 May 2007 Posts: 142
|
|
| Back to top |
|
 |
vashk
Joined: 07 Jan 2008 Posts: 11
|
Posted: Fri Jan 18, 2008 3:50 am Post subject: |
|
|
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 |
|
 |
|