Jump to content
Sign in to follow this  
Quiesel

Move mouse to object in scrollable div

Recommended Posts

Quiesel

Hello AutoIT Community,

I am trying to right click a link in a div that is not viewable before scrolling down, but I have no more ideas left how to reach that goal.

Here is what I currently do:

- Search and find the div

- _IEAction($oDiv, "focus") ;Div is now in the visible area (scrolled down)

- Calculate screenposition of $oDiv

- MouseClick("secondary", $x, $y)

It does what it should but it clicks at the screen where the div was before focusing it, therefore clicking at the wrong position in the browser window.

I did a small script to show you my problem:

#include <ie.au3>
_IEErrorHandlerRegister()

$sHtml = "<html><head><title>Test</title></head><body><div style='border: 2px solid green; width: 250px; height: 100px; overflow: scroll;'><div style='border: 2px solid red; position: relative; width: 90px; height: 500px'><div class='notme' style='border: 1px solid black; height: 100px'>Notme</div><div class='notme' style='border: 1px solid black; height: 100px'>Notme</div><div class='notme' style='border: 1px solid black; height: 100px'>Notme</div><div class='notme' style='border: 1px solid black; height: 100px'>Notme</div><div id='selectme' style='height: 100px'><a href='#'>Select me</a></div></div></div></body></html>"

Local $oIE = _IECreate()
_IEBodyWriteHTML($oIE, $sHTML)
Local $oDiv = _IEGetObjById($oIE, "selectme")
_IEaction($oDiv,"focus")
Local $iScreenX = _IEPropertyGet($oDiv, "screenx")
Local $iScreenY = _IEPropertyGet($oDiv, "screeny")
Local $iWidth = _IEPropertyGet($oDiv, "width")
Local $iHeight = _IEPropertyGet($oDiv, "height")
MouseClick("secondary", $iScreenX + $iWidth / 2, $iScreenY + $iHeight / 2, 1 ,10)

The screenposition of $oDiv is not updated after focussing it.

Any ideas how to solve this problem would be highly appreciated.

Best regards,

Chris

Share this post


Link to post
Share on other sites
Bert

You may want to use the other IE commands to do what you have in mind. I'm not that experienced with them but I do know (I hope I'm right here) you can reference a link directly after performing a collection. Look at the examples in the help file and you will see what I'm talking about.

Share this post


Link to post
Share on other sites
jdelaney

_IEaction, with action = Focus, brings that element into focus, and visiblitiy.

Why are you attempting right click?  You can get the href, and open in a new window.


IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

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  

×