Sign in to follow this  
Followers 0
dusty071

IE screenx property messes up if you scroll, how to fix?

6 posts in this topic

Hi, im trying to find the exact coordinates of IE object on the screen. _IEPropertyGet($oDiv, "screeny") gets the closest, since its correct until you scroll down. The coordinates stay in place even if you scroll, making the screen coordinates of that element wrong the moment you start scrolling. Ive been trying to find the current number of pixels that the page is scrolled and then add it to the screeny property, but none of the functions im finding dont seem to return the current scrolled value. I tried $oIE.document.window.pageYOffset , .scrolltop, etc. Maybe im not using them correctly, or they just dont work. Help much appreciated.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

You have to recalculate after Each Scroll

I had an idea for you may you can use

#include <Misc.au3>

If _Ispressed ("***") 

Then "recalculate"

The only unknow thing is, i am not sure you have an exa code for the mouse scroll ... "?"

Or even maybe that :

If MouseWheel ( "up") or MouseWheel ( "down")

Then "recalculate "
Edited by caramen

Share this post


Link to post
Share on other sites

Example:

#include <IE.au3>

HotKeySet("{NUMPADADD}", "_mousemove")

$oIE = _IECreate("http://www.autoitscript.com/forum/topic/164509-ie-screenx-property-messes-up-if-you-scroll-how-to-fix/")
$oDiv = _IEGetObjById($oIE, "post_id_1200002")

;if i use scrollintoview which i need to, the coords get wrong since any type of scrolling ruins screenx and screeny
;_IEAction($oDiv, "scrollintoview")

While 1
   ToolTip("screenx: " & _IEPropertyGet($oDiv, "screenx") & "  screeny: " & _IEPropertyGet($oDiv, "screeny"), 0, 0)
   Sleep(1000)
WEnd

Func _mousemove()
      MouseMove(_IEPropertyGet($oDiv, "screenx"), _IEPropertyGet($oDiv, "screeny"), 0)
EndFunc

You can use numpad+ to test the coords. You can see that the coords are correct even if you move the window around, but the moment you do any type of scrolling the coords are ruined. I think i only need the number of pixels that the page is scrolled at the moment so that i can add it to the screeny.

Share this post


Link to post
Share on other sites

Focus brings the object into view...no need for complicated movements

_IEAction($oObj,"Focus")
1 person likes this

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

You can use numpad+ to test the coords. You can see that the coords are correct even if you move the window around, but the moment you do any type of scrolling the coords are ruined. I think i only need the number of pixels that the page is scrolled at the moment so that i can add it to the screeny.

 

Try coordinate mode with windows and use the methode i said you , logicaly it should work.

Share this post


Link to post
Share on other sites

Maybe try :  _IEPropertyGet  "browserx" and "browsery" + WinGetPos(browser)

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