Jump to content

Get link title/hint at mouse position in IE


Recommended Posts

Hi.

Here´s a tricky one ;)

I need to get the link title/hint that displays for the mouse position.

Say my mouse is positioned on 400x150 in IE, there is a hyperlink exactly there and therefore IE displays a yellow box with the link title in it.

I need the information in the yellow box.

Have read through the forum posts and also ie.au3 but havent found any hints.

Thanks in advance...

autoit.jpg

 

Link to comment
Share on other sites

You can get the element below the mouse cursor with the following code:

$evt = $oIE.document.createEventObject()

$oElement = $oIE.document.elementFromPoint($evt.clientX, $evt.clientY)

If IsObj($oElement) Then
   ; Your custom code here
EndIf

From there, your should be able to use something like $oElement.Title or $oElement.Parent.Title in order to access the desired information.

Link to comment
Share on other sites

An other way ...

#include <IE.au3> 

$oIE = ObjCreate("InternetExplorer.Application")
$oIE.visible = 1
$oIE.navigate("http://www.autoitscript.com/forum/")
While $oIE.Busy
    Sleep(10)
Wend

$oLinks = _IELinkGetCollection($oIE)
For $oLink In $oLinks
    ObjEvent($oLink, "_Evt_")
Next

While 1
  Sleep(10)
WEnd

Func _Evt_onMouseover()
    Local $o_link = @COM_EventObj
   $cursor = MouseGetCursor()
   If $cursor = 16 Then MsgBox(4096, "",  $o_link.title)
EndFunc
Link to comment
Share on other sites

  • Moderators

I improved mikell's example.

#include <IE.au3>

$sURL = "http://www.autoitscript.com/forum/"
$oIE = _IECreate($sURL)
$HWND = _IEPropertyGet($oIE, "hwnd")
$oLinks = _IELinkGetCollection($oIE)

For $oLink In $oLinks
    ObjEvent($oLink, "_Evt_")
Next
ConsoleWrite("Done adding object events." & @CRLF)

While WinExists($HWND)
    Sleep(10)
WEnd

Func _Evt_onMouseover()
    Local $o_link = @COM_EventObj
    If IsString($o_link.title) Then ConsoleWrite($o_link.title & @CRLF)
EndFunc
Link to comment
Share on other sites

  • 3 weeks later...

Sorry, still dont get it.

As far as i can see, no data is put into a variable or echoed.

What is the "your custom code here"?

 

From there, your should be able to use something like $oElement.Title or $oElement.Parent.Title in order to access the desired information.

 

Essentially what I stated above. At that point, you have a reference to the element that was beneath the mouse cursor at the time that the hotkey was pressed. You can execute a command such as:

$itemText = $oElement.Title

or

$itemText = $oElement.Parent.Title

depending on your target on the web page.

Link to comment
Share on other sites

Ok, so i did this but still no luck.

#include <IE.au3> 
HotKeySet("{F2}", "getlink")

$oIE = ObjCreate("InternetExplorer.Application")
$oIE.visible = 1
$oIE.navigate("http://www.google.se")

While $oIE.Busy
    Sleep(10)
Wend

While 1
    Sleep(100)
WEnd

Func getlink()
$evt = $oIE.document.createEventObject() 
$oElement = $oIE.document.elementFromPoint($evt.clientX, $evt.clientY) 

    If IsObj($oElement) Then    
        $itemText = $oElement.Parent.Title
        MsgBox(4096, "",  $itemText)
    EndIf
EndFunc
Link to comment
Share on other sites

You said "no luck", but you didn't say what the results were or if it even ran successfully. When I attempted it with your code, it errored out on the $oElement.Parent.Title line, because the Parent element doesn't have a Title property.

I've shown you how to get the object reference to the element below the mouse pointer. You will need to "play around" to determine the exact code necessary to retrieve the desired information.

Hint: For the Google site you referenced, the following should work:

$itemText = $oElement.innerText
Link to comment
Share on other sites

I am abandoning this shit and posting on rentacoder instead.

I did just humbly ask for some help, did not force anyone to answer or even read the post.

Go and bully someone else fuckfaces!

What in the world happened here?  You were getting help, why are you mad?

Link to comment
Share on other sites

  • Developers

I am abandoning this shit and posting on rentacoder instead.

I did just humbly ask for some help, did not force anyone to answer or even read the post.

Go and bully someone else fuckfaces!

 

it's indeed better you move on and get help else were... either programming or psychiatrist

*Click*

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

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