+1 for sikuli. Very nice little tool that makes it very easy to do something that would otherwise require a lot of specific knowledge
I've used it to automate simple web games for shits and giggles.
PyAutoGui is another nice option - https://pyautogui.readthedocs.io/en/latest/ - cross platform Python module for keyboard and mouse automation with some support for taking and analysing screenshots.