Sign in to follow this  
Followers 0

Get text under mouse in Firefox

1 post in this topic

#1 ·  Posted (edited)

This is from one of my responses to a support posting here:

I'm posting it in scripts and scraps too because I think it's really cool, and has a lot of potential. I think using MSA might provide us with a way of automating Firefox similar to what we can do with IE. I know some people here would really be interested in that possibility. This page:

seems to indicate that quite a bit of the DOM would be accessible to us. However, I am clueless as to how to proceed, or whether we even can just using COM.

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:

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

winwait("IAccessible Test")
$hwnd = WinGetHandle("IAccessible Test","")
$cHwnd = ControlGetHandle($hwnd,"","Edit1")
$oldtext = ""
while 1
    $text = ControlGetText ($hwnd, "text", $cHwnd)
    if $text <> $oldtext Then
        $oldtext = $text
        $pos = MouseGetPos()
        ToolTip ($text , $pos[0]+10 , $pos[1]+10)
    if not winexists($hwnd) then exitloop

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[*][/list][/font]

Share this post

Link to post
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
Sign in to follow this  
Followers 0