Jump to content

Recommended Posts

Posted

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

 

Posted

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.

Posted

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
  • Moderators
Posted

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
  • 3 weeks later...
Posted

Thanks, it seems to work ok with some pages and some pages not at all.

If i for exaple browse to google, it will only display 0.

Havent tried the first example since i dont understand that at all.

Posted

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"?

Posted

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.

Posted

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
Posted

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
Posted

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!

Posted

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?

  • Developers
Posted

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.
  :)

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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