0
votes

I have a script that sends End key keystroke when i open specific page in Firefox, it scrolls automaticly to the bottom of the page. The problem is that i can't scroll upwards on that page any more. If i press Home or PgUp key or scroll up with the mouse it automaticly scrolls back to the bottom of the page.

This is the script. As example i am using google page:

#Persistent
SetTimer, check , 500
return

check:
WinGetActiveTitle, OutputVar 
If Instr(Outputvar, "google")
    Send {End}
return

Any idea how to fix this?

1

1 Answers

0
votes

Right at the beginning: This shouldn't be done with AHK! The biggest problem is that AHK can't know when your page finished loading. Depending on your internet connection and of course the server's response time, this can and will fluctuate unpredictably. If you scroll to the bottom too early, the page may load a wall of resources and you'll end up somewhere in the middle or even at the top. In contrast, if you wait a huge amount of time before scrolling down, you'll end up twirling your thumbs in many cases.
To automate browsers/webpages, there are far better ways like using userscripts in GreaseMonkey. If you desparately want to use AHK despite all that, check out this code:

SetTimer, ScrollDown, -1

Exit

ScrollDown:
    Loop {
        WinWaitActive, Google ahk_class MozillaWindowClass
        ; How long shall we wait? Not waiting will definitely fail, 
        ; since the <title> tag is loaded way before anything else on the page
        Sleep, 2000
        Send {End}
        WinWaitNotActive
    }
return