Jump to content

Help to translators - read active editctrl in ANY sw


Recommended Posts

Hi,

I am a translator.

I have a long list of (technical) words which substitute for "simple-looking" everyday words.

I would like to write a script which reads out the text which I'm typing and suggest words from the list (from file) based on the words it reads out.

The problem is that I want to make it universal because I use more softwares normally. In one minute I translate in InDesign, then jump to Illustrator, then to Word and maybe to Notepad. (I know I have a crazy environment, but client wants it this way unfortunatelly!!) I also do translation in Framemaker, Powerpoint, Excel, etc...

Is it possible to periodically read out my typed text from virtually ANY EDITCTRL-like gui window?

Different programs give very different titles for their edit windows and Excel translation is not even typed in a window, but in a "cell".

Maybe something to with the processlist command?

As a start I tried with Mozilla Mail Compose window (Send new letter) with no luck of reading out the text even after excessive use of Window Info Tool.

Thanks for any direction you might give.

Edited by Ármányos Kő
Link to comment
Share on other sites

It might be best to use the ClipGet and ClipPut clipboard functions. Then it really will work with any application. Assign a translate hotkey, and have it maybe detect the current application, send Ctrl-A (select all in most apps), send Ctrl-C (copy in hopefully all apps) and then do clipget.

Good luck with your project.

[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Link to comment
Share on other sites

It might be best to use the ClipGet and ClipPut clipboard functions. Then it really will work with any application. Assign a translate hotkey, and have it maybe detect the current application, send Ctrl-A (select all in most apps), send Ctrl-C (copy in hopefully all apps) and then do clipget.

Good luck with your project.

Yeah, yeah, but.

Unfortunatelly sending Ctrl+A, Ctrl+C takes time (in DTP softwares sometimes very long time) and while typing fast in the wrong millisecond, it may delete the whole data.

And before touching the famously-hated keylogger topic, that is far no use for this stuff, as that solution gives shuffled result if mouse is used for dropping the cursor in different places of the text.

Can you guys think of anything else?

thx

Link to comment
Share on other sites

I stumbled upon MSAA or MSA, meaning Microsoft Active Accessibility, which sounds like it might provide what you're looking for. The trouble is that obtaining an IAccessible object with the commands AccessibleObjectFromWindow or AccessibleObjectFromPoint from oleacc.dll is not something that I know how to do. Perhaps someone on this forum whose kung fu is superior to mine could take a crack at it.

In the mean time, someone named Jose Roca has provided some PowerBASIC samples that include a nifty EXE which is easily scrapable in AutoIt. Take a look here:

http://com.it-berater.org/other_wrappers.htm

Scroll to the bottom and download TB_IACCS.zip, extract it, and create Iaccessible.au3:

run("EX_TestIAcc_01.exe")
winwait("IAccessible Test")
$hwnd = WinGetHandle("IAccessible Test","")
$cHwnd = ControlGetHandle($hwnd,"","Edit1")
$oldtext = ""
while 1
    sleep(100)
    $text = ControlGetText ($hwnd, "text", $cHwnd)
    if $text <> $oldtext Then
        $oldtext = $text
        $pos = MouseGetPos()
        ToolTip ($text , $pos[0] , $pos[1])
    EndIf
    if not winexists($hwnd) then exitloop
WEnd

This works pretty well on established software. I can even hover my mouse over text in Firefox and AutoIt can retreive the text, even from an Input tag. This could be the basis for your translation script, but the way I have implemented it is extremely unsatisfying.

Edited by lod3n

[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Link to comment
Share on other sites

This works pretty well on established software. I can even hover my mouse over text in Firefox and AutoIt can retreive the text, even from an Input tag. This could be the basis for your translation script, but the way I have implemented it is extremely unsatisfying.

Hey, MANY THANKS!

Your second suggestion looks pretty promising! I will have a deeper look this night.

The MSAA thing is still a bit further away for me I think, but I will keep that in mind.

The Activewords sw could also be a good point, but hey, this is something I do not want to pay for! :P

I fell (again) in deep love of free sw-s after seeing this forum so reactive. :)

Thanks again, I'll keep news posted.

In the meantime, if anyone can tell me a bit more about this DLL readout stuff would be fantastic. How do you get info on entry points and return codes of a specific DLL? The other day I tried to fool user32.dll just for testing. I wanted to see if similarly to _Ispressed function I could make _IsbeingPressed function by altering the keyword which the function calls. No success. Altough I did know the right keyword from MS .net web.

Link to comment
Share on other sites

I am really surprised that it doesn't work for Word. MSA is Microsoft's own accessibility standard. Thats just shameful.

Well, you might have some luck with Big_Daddy's Word UDFs

http://www.autoitscript.com/forum/index.php?showtopic=30461

Start with attaching to the current Word instance with _WordAttach()

I dont know about Composer. Does anything show up in the AutoIt Window Info Tool?

[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...