Good evening! Do you already know the pyautogui Module? Its a python module that can send virtual keypresses and mouse clicks to your Operating System. Depending on your OS you might have to install different dependencies. For Linux you need to run:
sudo pip3 install python3-xlib sudo apt-get install scrot python3-tk python3-dev
Then you can run pip3 install pyautogui. If your program somehow gets out of control on Linux you can Logout with Ctrl-Alt-Del. Also you can include short pauses into your program so you gain back control of the mouse or keyboard. For the mouse movements you make use of the x and y-coordinates of your screen.
Here are some functions of the PyAutoGUI:
Read more about the PyAutoGUI here:
What kind of automation tools or frameworks have you already been using? I love automating stuff. :D Have a nice evening!