Sign in to follow this  
Followers 0
sigil

Get URL from hyperlink under mouse pointer

4 posts in this topic

In IE, how can I collect the hyperlink from whatever object the mouse is over? I tried

_iepropertyget($ieobj,"locationurl")

but that just gave me the current page's URL.

Sorry if this has been covered already--I searched the forum and didn't find anything.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Try this

#include <IE.au3>
 
 
$_statustextOld=''
$oIE = _IECreate ( "http://www.autoitscript.com/forum/topic/132993-get-url-from-hyperlink-under-mouse-pointer/" )
 
While 1
    $_statustext = _IEPropertyGet ( $oIE, "statustext" )
    If $_statustext And $_statustext <> $_statustextOld Then
         If StringLeft ( $_statustext, 5 ) = 'http:' Then ConsoleWrite ( "$_statustext : " & $_statustext & @Crlf )
         $_statustextOld = $_statustext
    EndIf
WEnd
Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

Thanks, that solves it! I look forward to getting better acquainted with my new friend .statusText.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Thanks, that solves it! I look forward to getting better acquainted with my new friend .statusText.

Ok, and you can try this way too :

#include <IE.au3>
 
$oIE = _IECreate ( "http://www.autoitscript.com/forum/" )
$hIE = _IEPropertyGet ( $oIE, "HWND" )
$o_linkOld = ''
$uIEOld = ''
 
While 1
    Sleep ( 100 )
    If Not WinExists ( $hIE ) Then ExitLoop
    $uIE = _IEPropertyGet ( $oIE, "locationurl" )
    If $uIE And $uIE <> $uIEOld Then
        ConsoleWrite ( "+->-- New Url : " & $uIE & @Crlf )
        _IELoadWait ( $oIE )
        $oLinks = _IELinkGetCollection ( $oIE )
        For $oLink in $oLinks
             $sLinkId = _IEPropertyGet ( $oLink, "uniqueid" )
            _IEHeadInsertEventScript ( $oIE, $sLinkId, "onmouseover", "return false;" )
            ObjEvent ( $oLink, "_OnMouseOver" )
        Next
        $uIEOld = $uIE
    EndIf
WEnd
 
Func _OnMouseOver ( )
    Local $o_link = @COM_EventObj
    If $o_link <> $o_linkOld Then
        If StringInStr ( $o_link.href, '//' ) Then ConsoleWrite ( $o_link.href & @Crlf )
       $o_linkOld = $o_link
    EndIf
EndFunc ;==> _OnMouseOver ( )
Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

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