Sign in to follow this  
Followers 0
Gibbo

Autoscroll on a webpage

12 posts in this topic

Hello all,

I am currently trying to make an auto scroller for some webpages that will be on display and I have hit a bit of an odd problem.

"$oIE.document.parentwindow.scroll" and "$oIE.document.parentwindow.scrollto" work on some webpages and not on others.

#include <IE.au3>
$oIE = _IECreate("www.themercury.com.au")
$iSleepTime = 15000
$iScrollTime = Round($iSleepTime / $oIE.document.body.clientHeight)
For $scroll = 1 To $oIE.document.body.clientHeight
    Sleep($iScrollTime)
    $oIE.document.parentwindow.scrollto(0, $scroll)
Next

Works fine.

However

#include <IE.au3>
$oIE = _IECreate("northerntasmania.yourguide.com.au")
$iSleepTime = 15000
$iScrollTime = Round($iSleepTime / $oIE.document.body.clientHeight)
For $scroll = 1 To $oIE.document.body.clientHeight
    Sleep($iScrollTime)
    $oIE.document.parentwindow.scrollto(0, $scroll)
Next

Does not. :P

The error returned is:

$oIE.document.parentwindow.scrollto(0, $scroll)
$oIE.document.parentwindow.scrollto(0, $scroll)^ ERROR

The other problem is that on the pages that work it never scrolls all the way to the bottom. I have a feeling this isn't fixable as "$oIE.document.body.clientHeight" probably doesn't return the correct value.

The browser is IE7

Any ideas would be greatly appreciated. :(

Share this post


Link to post
Share on other sites



both pages scroll for me

both go all the way to the end of the page

both give almost* the same error

maybe it is being closed wrong

I'm using IE7.0.5730.11

*this is the error from the first code block going to www.themercury.com.au

>Running:(3.2.12.1):C:\Program Files\AutoIt3\autoit3.exe "c:\Temp\SciTE-temp.au3"

C:\Temp\SciTE-temp.au3 (7) : ==> The requested action with this object has failed.:

$oIE.document.parentwindow.scrollto(0, $scroll)

$oIE.document^ ERROR

->07:28:14 AutoIT3.exe ended.rc:1

>Exit code: 1 Time: 69.052

*the error from the code going to northerntasmania.yourguide.com.au is as you posted


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

both pages scroll for me

both go all the way to the end of the page

both give almost* the same error

If they both give (almost) the same error, then I asume you mean you are able to scroll all the way through the pages manualy. The line that is giving you the error is the one that is supposed to scroll through automaticaly.

maybe it is being closed wrong

Internet Explorer? It closes fine. Just doesn't scroll.

I'm using IE7.0.5730.11

I'm using IE7.0.5730.13

it all boils down to getting ".document.parentwindow.scrollto" to work. Consistently.

Share this post


Link to post
Share on other sites

Sorry that I was not clear:

both go all the way to the end of the page automatically

A bit more info:

Today I tried both on another computer that is using IE7.0.5730.13 and the same version of AutoIt --- but, I had the output pane of SciTE in view while the script ran. After the auto-scroll reached the end of the page, there was a second or so and then the script ended without error.

I repeated this several times for both websites. Each scrolled to the bottom of the page as expected and both give an error if I exit that IE window before the script has ended on its own.

So - if some setting is preventing the scroll from happing for you, then you will get the error. I only get it after I kill the window spawned by the script and only if I do that too soon. Do you see this error before killing the spawned IE window?

I know very little about IE.au3 ... but I can test and guess. :-)

Warning: Some might consider a female pole dancer not safe for work... but the pic is small and hopefully our corporate keyword filter won't raise a flag.


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

Now I am even more stumped.

I have the exact same version of autoit and IE7 and it works perfectly on one page and not the other.

The error occurs as soon as it calls the ".document.parentwindow.scrollTo" line for the first time. The window is never closed.

So - if some setting is preventing the scroll from happing for you, then you will get the error.

Any idea what that setting could be that prevents accessing ".document.parentwindow.scrollTo" on one page but not on the other?

Warning: Some might consider a female pole dancer not safe for work... but the pic is small and hopefully our corporate keyword filter won't raise a flag.

:P

It is a completely legit news site. Allthough I didn't realise there was a story about pole dancing there today :(

Share this post


Link to post
Share on other sites

... Any idea what that setting could be that prevents accessing ".document.parentwindow.scrollTo" on one page but not on the other? ...

Not really - I tried toggling "Use smooth scrolling" but both pages still worked for me. Maybe it has something to do with IE add-ons. It might be time to rattle Dale's cage. Let me PM him for you.

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

Now I am convinced it is a setting in windows. Just have NO idea what it could be.

I logged on to another computer and it ran perfectly. This left me scratching my head for a bit, untill it refused to visit some pages. I realised I had logged on as the Administrator and thus had no proxy support (authentication is done via domain logons). I logged in as me and found the problem was back, even though I am also an administrator.

I even tried various other accounts, same result.

So I am left with

1. Run as administrator. Scroll works, external sites don't.

2. Run as a user. Scroll is broken, external sites work.

:P

Share this post


Link to post
Share on other sites

I cannot get it to fail.

Suggest you start by putting this in your code:

_IEErrorHandlerRegister()

see if anything interesting is written to the console.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

...

I even tried various other accounts, same result.

So I am left with

1. Run as administrator. Scroll works, external sites don't.

2. Run as a user. Scroll is broken, external sites work.

:P

I think, you have not the same zonesettings.

Please check this settings.

Share this post


Link to post
Share on other sites

I cannot get it to fail.

Suggest you start by putting this in your code:

_IEErrorHandlerRegister()

see if anything interesting is written to the console.

Dale

This has the added benefit of allowing you to trap and handle COM errors or simply continue on without them being fatal to your script.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

... It might be time to rattle Dale's cage. Let me PM him for you.

Thanks Dale for stopping by this thread.

I'm sure that you get a lot of PMs about your IE.au3 UDFs since no good deed goes unpunished :-)


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

I cannot get it to fail.

Suggest you start by putting this in your code:

_IEErrorHandlerRegister()

see if anything interesting is written to the console.

Dale

Thanks Dale! I didn't know about the "_IEErrorHandlerRegister()"

(probably my fault for not looking past my nose :P )

--> COM Error Encountered in Webslide.au3
----> $IEComErrorScriptline = 45

$oIE.document.parentwindow.scrollto(0,$scroll) <-- that is line 45

----> $IEComErrorNumberHex = 80020009
----> $IEComErrorNumber = -2147352567
----> $IEComErrorWinDescription = Access is denied.
----> $IEComErrorDescription = Access is denied.
----> $IEComErrorSource = 
----> $IEComErrorHelpFile = C:\WINDOWS\system32\mshtml.hlp
----> $IEComErrorHelpContext = 0
----> $IEComErrorLastDllError = 0

I think, you have not the same zonesettings.

I just pushed the "reset all zones to default settings" with no effect on the output.

Not exactly sure why I would be getting "Access is denied" as I am an Administrator.

Any ideas on other settings I could check?

Thanks for everyones help so far!

:(

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