Nik Edmiidz
Nik Edmiidz

Reputation: 72

How do you use pyautogui to scroll to the top of a page?

I can use something like this:

pyautogui.scroll(200) 

with a large number to scroll to the top, however I'm wondering if there is a more elegant solution.

Upvotes: 0

Views: 2507

Answers (1)

bfris
bfris

Reputation: 5805

You haven't said what program you're using to scroll. But in many programs ctl+home jumps to the top of a document/window and ctl+end jumps to the end of a document/window.

import pyautogui

# click somewhere in the window to activate the window
# change x, y for your configuration
pyautogui.click(x=100, y=200)
pyautogui.hotkey('ctrl', 'home')

Upvotes: 1

Related Questions