asweigart / pyautogui

A cross-platform GUI automation Python module for human beings. Used to programmatically control the mouse & keyboard.
BSD 3-Clause "New" or "Revised" License
10.24k stars 1.24k forks source link

Scroll not working properly #665

Open doncezart opened 2 years ago

doncezart commented 2 years ago

Regarding pyautogui.scroll(). Found another similar issue, someone said to input a large number of clicks so I did it, 100, 200, 500, nothing. At 1000, I noticed the screen scrolls only on one app, and only up (I need down). Any way to diagnose and fix the problem?

InfamousPlatypus commented 2 years ago

Most projects I have worked on will request more info, so I'll start there. At the very least, what operating system? What Python version? Also if I remember from my experimenting, the app that you want to scroll needs to be the one with the focus. Have you selected the app first? I had trouble using things I didn't realize I changed the focus on when doing it manually.

JayRizzo commented 2 years ago

HI @goldieczr, I hope you are doing well.

Ahhh.... So many things have changed in python in the last few years.

Keep in mind, it is not just the scrolling, it is also, how fast the computer is recognizing you scroll That has the biggest impact as well.

The use of the code & how you implement it may play a role, as so many other factors.

My tinkering (story time, lol)

After using PyAutoGUI for years now, man the struggles i have gone thru with bottle necking of the CPU in tying to click a Million times an hour. You are going to run into some various issues, believe me I have had mine. I have used pyautogui to replicate me playing a game on my laptop, for a game called Realm Grinder here's my code.

Now this got more interesting as time went on, you see the game gets more complex & has to do crazy amounts of mathematical calculations per second, so as you level up each "Click" becomes more taxing on the computer. Well when you get to 1E300+ OR 1 Novemnonagintillion (yes a real number lol sorry numbers are facinating) my computer was a Croakin'.
Anyway you will figure out the sweet spot, but it will take time.

Ref: https://realm-grinder.fandom.com/wiki/Notation Ref2: https://googology.fandom.com/wiki/List_of_googolisms

Other items to keep an eye on.

Computer Scrolling matching your Scrolling?

If you scroll your mouse and it behaves the same. It's the program you are using not PyAutoGUI. Different programs don't always behave the same.. Example Twitter doesn't scroll like iTunes.

Which can be programmed specifically by each developer of each program (Google / Spotify / iTunes / Microsoft / Linux / Python / Bash etc.) & same is true for websites they can force your scroll to mean less like when scrolling past an Ad.

Bluetooth Vs Wired

Bluetooth vs Wired has a role too. if you are using a wireless mouse and comparing to code, you might see a discrepancy, as wireless has interference & battery strength, and code is direct.

System Settings

This can also be controlled by your system settings, this may have an impact on the behaviour of the interaction under your Mouse Settings -> Scrolling Speed/Sensitivity.

CPU & I/O Bottlenecking

As I mentioned above PyAutoGUI is only as fast as your computer will allow. My Click speed for my mac running the game & the game processing them as if it was me was click_speed=0.037 about 27 times a second the other program could register.

Cosmic Rays (rare)

Very rare, but Election interference and game glitches. Fun watch. https://www.youtube.com/watch?v=AaZ_RSt0KP8

If you do still think this is a problem, please provide your code & as much detail so others can try to replicate it to investigate further.

Good luck I hope that helps in providing a different perspective.

Thanks for reading all! lol

Have a Great Day all!