Python Forum

Full Version: Check for specific values on screen
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am building an autoclicker tool atm with pyautogui and want to make it more intelligent. So I want to replace the wait function with a screen checking modul. For example: Starting a programm that needs 3-5sec for starting. While loading, the screen is for example white at a specific area and when the programm has loaded there are also black colors. Instead of setting a wait function, is there a py modul that can check if the screen has black colors on my screen at the specific area of my screen?
First off I would highly suggest using a different library such as pynput because pyautogui is very slow. For what you want to do, you'll have to use a combination of two libraries. PIL and cv2. More specifically you just need ImageGrab from PIL, and then cv2 to read it. cv2 will return the data of an image as a list. The list contains more lists each of those is a row. Each row contains a list of colors (I believe) in the form of an rgb list. The thing is you'll have to optimize your code to be as efficient as possible because it can take time to go through so many lists. So the image that you grab should also be as small as possible. Hope this helps
Hey SheeppOSU,

that helps definetly. Thx for that detailed answer.