JonnyF Posted July 15, 2013 Share Posted July 15, 2013 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... Link to comment Share on other sites More sharing options...
Danp2 Posted July 15, 2013 Share Posted July 15, 2013 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. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
mikell Posted July 15, 2013 Share Posted July 15, 2013 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 More sharing options...
Moderators big_daddy Posted July 15, 2013 Moderators Share Posted July 15, 2013 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 More sharing options...
JonnyF Posted August 2, 2013 Author Share Posted August 2, 2013 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. Link to comment Share on other sites More sharing options...
Danp2 Posted August 2, 2013 Share Posted August 2, 2013 Havent tried the first example since i dont understand that at all. Setup a hotkey using HotKeySet, and then this code goes into the user function called when the hotkey is pressed. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
JonnyF Posted August 2, 2013 Author Share Posted August 2, 2013 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"? Link to comment Share on other sites More sharing options...
Danp2 Posted August 2, 2013 Share Posted August 2, 2013 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. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
JonnyF Posted August 2, 2013 Author Share Posted August 2, 2013 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 More sharing options...
Danp2 Posted August 2, 2013 Share Posted August 2, 2013 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 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
mikell Posted August 2, 2013 Share Posted August 2, 2013 God helps those who help themselves Link to comment Share on other sites More sharing options...
JonnyF Posted August 2, 2013 Author Share Posted August 2, 2013 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! Link to comment Share on other sites More sharing options...
DW1 Posted August 2, 2013 Share Posted August 2, 2013 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? AutoIt3 Online Help Link to comment Share on other sites More sharing options...
Developers Jos Posted August 2, 2013 Developers Share Posted August 2, 2013 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 More sharing options...
Recommended Posts