Automate the boring stuff: Chapter 18 – Controlling the Keyboard and Mouse with GUI Automation
This is a great book. Lots of amazing coders started out with it. You don’t need to read the whole thing, but it is generally very very useful.
https://automatetheboringstuff.com/2e/chapter20/